question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FCM.presentLocalNotification not working on iOS

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:64 (29 by maintainers)

github_iconTop GitHub Comments

1reaction
evollucommented, Dec 16, 2016

sure you can do the work around. I will play with it myself and figure out the fix.

1reaction
evollucommented, Dec 16, 2016

there must be a way, let me check

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remote push notification not firing off using react native fcm
I have all of my capabilities check on in Xcode, I'm running this on an iOS 8 Device, and I'm using react-native-fcm 16.0.0...
Read more >
App does not launch by data FCM | Apple Developer Forums
I'm facing similar issue under these conditions: Running on iOS 15.2 (19C5044b); App is running in foreground and is actively receiving touch inputs;...
Read more >
evollu/react-native-fcm - Gitter
this version of presentLocalNotification stops the App really bad. ... I've got FCM installed and notifications are showing up in my emulator (though...
Read more >
react-native-fcm-fix: Documentation - Openbase
In firebase console, you can: for Android: download google-services.json file and place it in android/app directory; for iOS: download GoogleService-Info ...
Read more >
PushNotificationIOS.presentLocalNotification() doesn't work in ...
presentLocalNotification () doesn't work in react-native. ... after dismissing a modally presented ViewController · Uiswitch does not change the state ios ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found