Can't receive push notifications using Ionic Cloud on iOS

时间:2017-06-12 16:56:26

标签: swift cordova ionic-framework ionic2 apple-push-notifications

I'm using ionic's cloud push notification service for both android and iOS, along with phonegap-plugin-push. Since i'm using my own server-side authentcation and not ionic's, I have it configured so that a user's authentication token is registered depending on whether or not they're logged in, and saved when they log in (unregistered when they log out).

App.module:

const cloudSettings: CloudSettings = {
  'core': {
    'app_id': 'APP_ID',
  },
  'push': {
    'sender_id': 'SENDER_ID',
    'pluginConfig': {
      'ios': {
        'badge': true,
        'sound': true,

      },
      'android': {
        'iconColor': '#343434'
      }
    }
  }
};

instead of making push a provider in app module, I made an injectable service that can be used across components. The main app component subscribes to the notifications, while my login and logout components tell it whether or not to register and save them.

export class NotificationService{

    token: PushToken;
    registered: boolean;


    constructor(public push: Push){

    }



  checkLogin(status){
    if(!status){
      this.push.register().then((pushT: PushToken) => {

      this.token = pushT;
      console.log('token saved:'+ this.token);
    });
  }
  }


saveToken(){
  this.push.saveToken(this.token);
  console.log('token saved');
  this.registered = true;
  this.startListening();
}
deleteToken(status){
  if(status){
    this.push.unregister().then(function(){
      console.log('token deleted');
      return true;
    })
  }
}

startListening(){
  if(this.registered){
  return this.push.rx.notification()
  .subscribe((msg) => {
    alert(msg.title + ': ' + msg.text);
  });
}}
getToken(){
  return this.token.token;
}

}

I have my sender ID for GCM configured in config.xml and ionic cloud, and my APNS certificate is saved in ionic cloud. So far this works perfectly on android. On iOS it registers the token and saves to the database, but testing on Ionic cloud my iPhone doesn't receive any notifications. Any thoughts?

0 个答案:

没有答案