fechanique / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
624 stars 999 forks source link

iOS onNotification never called #223

Open AndroideRob-zz opened 7 years ago

AndroideRob-zz commented 7 years ago

The notification is received when the app is off, tapping it results in the app opening (GOOD). However, on Android it also fires the FCMPlugin.onNotification(..) callback while on iOS it does not. What could be the problem? Sharing some code snippet. Thanks!

FCMPlugin.onNotification( function(data) { if (data.wasTapped) { alert(data['url']); } else { alert(data['url']); } } );

Is there a secret to enable onNotification for iOS? :)

m6246 commented 7 years ago

Same here: In Android, onNotification gets called both when app is in foreground and after focus fom tapping the notification. In iOS (iOS 9.3.5 on iPad2), onNotification is not being called when in foreground, nor after focus from tapping the notification. ie. not at all..

As all clients successfully receive registration ids and notifications on both platforms, I guess the FCM backend is setup correctly. When supplying the onNotification callback with error and success handlers, the success handler gets called with a null value.

Using the node-gcm library I am sending this payload from my server to FCM:

{ collapseKey: 'somekey', priority: 'high', restrictedPackageName: 'my.package.name', data: { action: 'turn' }, notification: { title: 'some title', icon: 'ic_launcher', body: 'some body', click_action: 'FCM_PLUGIN_ACTIVITY' } }

Using all the latest npm packages

jeiw commented 7 years ago

In this fork https://github.com/martin-podlubny/cordova-plugin-fcm you can find problem solution.

kapilrc commented 7 years ago

Many thanks, your solution worked. Please send pull request to the owner.

MadhusudhanDK commented 7 years ago

hi i too have same issue onNotification success call back is returning null and onNotification is not firing when i get notification.

alexandrunicolae commented 7 years ago

that fork doesn't solve problem on iOS 10, has anyone managed to display notifications in foreground on iOS 10+?

lp1bp commented 7 years ago

I'm facing the same problem, any update ?

arnoldmukisa commented 7 years ago

I solved this by uploading my APNs authentication key to Firebase. If you don't already have an APNs authentication key, see https://firebase.google.com/docs/cloud-messaging/ios/certs

Inside your project in the Firebase console, select the gear icon, select Project Settings, and then select the Cloud Messaging tab. In APNs authentication key under iOS app configuration, click the Upload button. Browse to the location where you saved your key, select it, and click Open. Add the key ID for the key (available in Certificates, Identifiers & Profiles in the Apple Developer Member Center) and click Upload.

pierrybos commented 7 years ago

+1

iOS 9 - iPad 2