Ionic 2 - iOS NotRegistered

I have done an App in Ionic 2 with the phonegap-plugin-push for notifications.

It works really well with Android but when I try to run it on the iOS it have a few problems.

I can get the registration token but when I do a push message I get the error: NotRegistered as response. Sometimes the first one I got a message sent response but I didn’t receive it on my device. But after that first one any other gives me that error.

What can it be? The wrong certeficates or some bug in code?

I’m using Ionic 2 on a windows, using phonegap to compile the app to iOS so I have to generate the certificates with openSSL.

There is a few of the code for the push notifications:

config.xml

<plugin name="phonegap-plugin-push" spec="1.8.2">
   <variable name="SENDER_ID" value="883847118563"/>
</plugin>

app.component.ts

import {Push, PushObject, PushOptions} from "@ionic-native/push";
(...)
platform.ready().then(() => {
  (...)
  this.initPushNotification();
});

initPushNotification() { 
if (!this.platform.is('cordova')) {
  (...)
}
const options: PushOptions = {
  android: {
    senderID: "8838XXXXXXXX"
  },
  ios: {
    senderID: "8838XXXXXXXX" ,
    gcmSandbox: "true",
    alert: "true",
    badge: false,
    sound: 'true'
  },
  windows: {}
};
const pushObject: PushObject = this.push.init(options);

pushObject.on('registration').subscribe((data: any) => {
  (...)
});

pushObject.on('notification').subscribe((data: any) => {
  (...)
});

pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));
}

app.module.ts

import { CloudSettings, CloudModule } from '@ionic/cloud-angular';

const cloudSettings: CloudSettings = {
 'core': {
  'app_id': 'bdeXXXX'
  },
'push': {
  'sender_id': '8838XXXXXXXX',
  'pluginConfig': {
    'ios': {
      'badge': true,
      'sound': true
     },
    'android': {
     'iconColor': '#ff0000'
    }
  }
 }
};

Thank you in advance for the help.

Where do you get this error? What exactly does it say?

In Postman… this is what I got:
{
“multicast_id”: 6003101976233628796,
“success”: 0,
“failure”: 1,
“canonical_ids”: 0,
“results”: [
{
“error”: “NotRegistered”
}
]
}

For what I have read it seams that something is wrong, so after my first push (succesfull) to APNs the server might give back some error and Firebase unregister my device…

Are you using Ionic Push as a push provider? Or what URL are you calling in Postman?

Just Firebase…
The URL is: https://fcm.googleapis.com/fcm/send

Hi, i’m getting the same error in ios, how did u solved this?

Hi, i’m getting the same error in ios, android works fine.
i’m using phone-plugin-push and url https://fcm.googleapis.com/fcm/send
Can u help me figure out why this is happening

Hello @cikcoh,

I’m sorry but I did this over an year ago and now I don’t really remember how I solved it, however, I can give you some tips.

For iOS compile your app using xCodes, normally what I do is:

ionic cordova build ios–release

Then go to:

“Source”\platforms\ios

And use your xCode projected file *.xcodeproj in xCode to compile.

After that check if you got the correct Apple certificates in your Firebase, it’s pretty confuse and I think this is your issue, getting the right certificate, I remember spending 4 hours looking for the correct certificate.

Hope it helps.

Hi, i found a workaround here iOS on FCM not working for debug signed apps + workaround · Issue #2518 · phonegap/phonegap-plugin-push · GitHub
it is caused by this:

It turns out that Cordova uses a hook during the ios-build, which removes the embedded.mobileprovision that Firebase uses to determine if this is a production app or not. Because this is missing, debug-only signed apps will not receive the correct FCM token when the plugin makes a request to Firebase.

Thanks for your help :slight_smile:

1 Like