react-native-fcm: FCM.presentLocalNotification not working on iOS
rn 39.2 rn-fcm: 2.5.2 iOS 10.1
The below method is not working on iOS 10.1, it does not show a local notification when the app is in foreground:
RCT_EXPORT_METHOD(presentLocalNotification:(id)data resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
if([UNUserNotificationCenter currentNotificationCenter] != nil){
UNNotificationRequest* request = [RCTConvert UNNotificationRequest:data];
[[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (!error) {
resolve(nil);
}else{
reject(@"notification_error", @"Failed to present local notificaton", error);
}
}];
}else{
UILocalNotification* notif = [RCTConvert UILocalNotification:data];
[RCTSharedApplication() presentLocalNotificationNow:notif];
resolve(nil);
}
}
However if I go back to the older code that it is only:
UILocalNotification* notif = [RCTConvert UILocalNotification:data];
[RCTSharedApplication() presentLocalNotificationNow:notif];
resolve(nil);
it works fine
how can I add logs on native code to debug properly this? or add a breaking point?
cc @MechanicKim had the same issue
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 64 (29 by maintainers)
sure you can do the work around. I will play with it myself and figure out the fix.
there must be a way, let me check
does it work if you comment out line 250-259
read me is correct. Setting APNS token is done by FCM SDK automatically. Are you seeing local notification not showing up or red screen?