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.