Hey i have some wired problems with the Push notifications from the Ionic cloud during the setup. I am using an Iphone with Ios 10. I am confused. The error basically says that the GCM Sender ID is null. But i defined it in my cloud settings. It’s may a bit lazy but the logs and my config is below. I think those once are saying more that thousand words.
The X-Code log from the point when “push.register()” is called:
- Push Plugin register called
- PushPlugin.register: setting badge to false
- PushPlugin.register: clear badge is set to 0
- PushPlugin.register: better button setup
- GCM Sender ID (null)
- Using APNS Notification
- Push Plugin register failed
My app.component.ts were i call push.register()
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { Auth, User, Push, PushToken } from '@ionic/cloud-angular';
import { TabsPage } from '../pages/tabs/tabs';
import { LoginPage } from '../pages/login/login';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage;
constructor(platform: Platform, public auth: Auth, public push: Push) {
platform.ready().then(() => {
StatusBar.styleDefault();
Splashscreen.hide();
if(this.auth.isAuthenticated() !== true){
this.rootPage = LoginPage;
}else{
this.rootPage = TabsPage;
}
this.push.register().then((t: PushToken) => {
return this.push.saveToken(t);
}).then((t: PushToken) => {
console.log('Token saved:', t.token);
});
this.push.rx.notification()
.subscribe((msg) => {
alert(msg.title + ': ' + msg.text);
});
});
}
}
My app.module.ts where i provide the cloud settings
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';
import { LoginPage } from '../pages/login/login';
import { CloudSettings, CloudModule, Push, PushToken } from '@ionic/cloud-angular';
const cloudSettings: CloudSettings = {
'core': {
'app_id': '12345'
},
'push': {
'sender_id': '777766677',
'pluginConfig': {
'ios': {
'badge': true,
'sound': true
},
'android': {
'iconColor': '#343434'
}
}
}
};
@NgModule({
declarations: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage,
LoginPage
],
imports: [
IonicModule.forRoot(MyApp),
CloudModule.forRoot(cloudSettings)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage,
LoginPage
],
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}
Thank you for you help.