onNotification not working on iOS
I'm trying to send a push notification to iOS, but the method onNotification just didn't get called. I already configured PushNotificationIOS according to RN Docs, I enabled Push Notifications in developer account and in my project capabilites. That is my code to configure in JS:
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: function(token) {
Auth.saveNotificationToken(token.token);
console.log( 'TOKEN:', token );
},
// (required) Called when a remote or local notification is opened or received
onNotification: function(notification) {
console.log( 'NOTIFICATION:', notification );
// process the notification
// required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
// ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
senderID: "87065697363",
// IOS ONLY (optional): default: all - Permissions to register.
permissions: {
alert: true,
badge: true,
sound: true
},
// Should the initial notification be popped automatically
// default: true
popInitialNotification: true,
/**
* (optional) default: true
* - Specified if permissions (ios) and token (android and ios) will requested or not,
* - if not, you must call PushNotificationsHandler.requestPermissions() later
*/
'content-available': 1,
requestPermissions: true,
});
Why did you close this? What did you resolve? I'm dealing with this same issue on iOS. No notifications received, looks just like yours.
Not sure why this issue would be closed without even addressing / commenting on it. From my experience, this is a valid issue on iOS 11. It seems like PushNotificationIOS is not updated to support iOS 11 (FYI - iOS 11 has a newer delegate method that you need to implement to get this working).
Custom coding maybe needed on AppDelegate since UILocalNotification object has been deprecated since iOS 11
React Native Push Notifications clearly states that we need to call configure outside of the React Native Lifecycle. This is very important.
https://product.farewell.io/visible-react-native-push-notifications-that-work-on-both-ios-and-android-5e90badb4a0f
https://prnt.sc/k61hz7
Still facing same issue. Does anyone have solution for this? I am using iPhone XS Max.