I’ve probably read ~ 50 posts on this topic, but none which seem to address the particular problem I’m having. While using Cordova’s push plugin using FCM and APNS, I’ve come across a problem where ALL push notifications to my iPhone appear as banner notifications. So far, I’ve:
- Created new ionic 2 project.
- Added to ionic.io
- Added phonegap-plugin-push plugin (with sender ID for Android, set up in FCM)
- Created Apple development certificate
- Created Apple push notification development SSL certificate
- Created Apple provisioning profile (development) - my iPhone device already registered
- Ionic.io - created development security profile, uploaded APN credentials, iOS app build credentials)
- ionic run android (on local device just to test - works perfect, push registers fine).
- Enabled Push Notifications in the Capabilities tab in XCode. All indications tell me that this feature is set up properly.
- ionic cordova build ios --debug, then run on iPhone via XCode
On Android phones and on iOS devices < iOS 10.0, the alerts show up more or less as expected. On iOS >= 10, I only get the banner notification like the app is in the background. Here is the code I have written:
in app.module.ts:
const cloudSettings: CloudSettings = {
'core': {
'app_id': 'APP_ID'
},
'push': {
'sender_id': 'SENDER_ID',
'pluginConfig': {
'ios': {
'badge': true,
'sound': true
},
'android': {
'iconColor': '#343434'
}
}
}
};
@NgModule({
declarations: [
[all my amazing declarations
],
imports: [
BrowserModule,
IonicModule.forRoot(myApp),
IonicStorageModule.forRoot(myApp),
CloudModule.forRoot(cloudSettings),
HttpModule
],
bootstrap: [IonicApp],
entryComponents: [
[all my fun pages]
],
providers: [
[All my providers]
]
})
export class AppModule {}
And in app.component.ts:
initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.statusBar.overlaysWebView(false);
this.statusBar.styleLightContent();
this.splashScreen.hide();
this.initPush();
});
}
initPush() {
//JJC Use this string to check the environment, enable/disable native app features
this.push.register().then((t: PushToken) => {
console.log('Token generated: ' + t.token);
return this.push.saveToken(t);
}).then((t: PushToken) => {
console.log('Token saved:', t.token);
}).catch((e:Error) => console.log(e));
this.push.rx.notification()
.subscribe((msg) => {
alert(msg.text);
}, ((err: any) => console.log('Notification did not work: ' + err)));
}
Is there a problem with how I’m handling the data, or is there some step I’ve missed in setting up APNS? When looking at the console, the APNS token is being generated and saved properly, and again it works fine on iOS < 10.0. Any help would be appreciated.
EDIT: here is a screenshot of the notification. The app open is indeed the application for which the notification was meant, but it should be showing as an alert.