Push Notifications GCM Sender ID is null


#1

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.


#2

Are you debugging with the XCode simulator or real device?

If I’m not wrong, it only works with a real phone and that may explain why you get a null ID


#3

I am running it on a real device. It’s an Iphone SE with Ios 10.


#4

:frowning:

Do you use the last version of XCode? Have you try to post your problem on the Github of the cordova push notification plugin?

Sorry I’m no expert, can’t really help more.


#5

I fixed it. I used the wrong team to sign my app. After changing the team and enabling push notifications. I got the token and everything is working.


#6

Kind of funny in a way… just upgrade from phonegap-plugin-push 1.9.2 to 1.9.4 and now I face the exact same problem :frowning:


#7

I removed my all platform, added it again, did all the settings and…it works again :wink:


#8

what mean changing the team. i have the same problem.


#9

If you don’t hear from that responder, they probably meant the apple developer certificate?