Closed felire closed 4 years ago
I will close it, I could fixed with this code:
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
NSDictionary *userInfo = notification.request.content.userInfo;
//Foreground
NSLog(@"APP_PUSH from foreground %@", userInfo);
[[FIRMessaging messaging] appDidReceiveMessage:userInfo];
[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo
fetchCompletionHandler:^void (UIBackgroundFetchResult result){}];
completionHandler(UNNotificationPresentationOptionAlert);
}
What is FIRMessaging
?
I removed FIRMessaging
//Called when a notification is delivered to a foreground app.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
NSDictionary *userInfo = notification.request.content.userInfo;
//Foreground
NSLog(@"APP_PUSH from foreground %@", userInfo);
[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo
fetchCompletionHandler:^void (UIBackgroundFetchResult result){}];
completionHandler(UNNotificationPresentationOptionAlert);
}
Please note that without this change the javascript handlers will not be notified when the app is in the foreground. This should probably be added to the readme?
@alexking I tried with & w/o this piece of code but still i am not getting any notification while app is in foreground.
@arnaudambro
I removed FIRMessaging
//Called when a notification is delivered to a foreground app. - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{ NSDictionary *userInfo = notification.request.content.userInfo; //Foreground NSLog(@"APP_PUSH from foreground %@", userInfo); [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:^void (UIBackgroundFetchResult result){}]; completionHandler(UNNotificationPresentationOptionAlert); }
Your code fixed the foreground triggering problem but if app is in background the listener won't trigger the callback function If you have a solution for this issue, that will be great.
I am using the latest updates of this lib react-native-community/push-notification-ios: 1.10.1 react-native-push-notification: 8.1.1 react-native: 0.67.3
@AhmedAbuelenin I'm not sure about what you're saying : as far as I remember it's working good on my apps. I will check again as soon as I have to go to push notifications again...
Bug report
Summary
Hi, I'm handling notification in Native way but I would like to add (using
react-native-push-notification
) anonNotification
method that refresh the Dashboard of my app when a notification arrives. Now, I'm able to handle the method when I click on the notification, but not when it arrives. Is there a way of doing that?Environment info
I'm using the last version of this library and the last version of react-native-push-notification.
Steps to reproduce
This is my code:
Describe what you expected to happen: