Open strawberry-code opened 3 years ago
I suspect you are looking for notification.request.content.userInfo
Hi - if you got this working could you share your solution? thanks!
I suspect you are looking for notification.request.content.userInfo
//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNNotificationPresentationOptionNone);
[RNCPushNotificationIOS didReceiveRemoteNotification:notification.request.content.userInfo];
}
it works for me, thanks~
Hi - if you got this working could you share your solution? thanks!
//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNNotificationPresentationOptionNone);
[RNCPushNotificationIOS didReceiveRemoteNotification:notification.request.content.userInfo];
}
Using react-native-push-notification-ios, I would like the notification to arrive, not be shown and the notification data to be passed to the React Native layer to the onNotification function.
To do this I have removed UNNotificationPresentationOptionAlert from the userNotificationCenter: willPresentNotification: withCompletionHandler function. However, I am not sure how to proceed for the object of the notification to be handled automatically delivered to React Native.
How can I do that?
The code presented below is what I am currently using. It works when notifications arrive, but they are not passed to React Native.
Update 1
I found a way to handle directly the notification, however its contents seems to be empty:
The code I adjusted above:
The result I get printed out in the Xcode console:
Finally React Native side I see "notification" coming, obviously it is empty as described above.
How can I get notification data here?