evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 681 forks source link

I am unable to get notification, when app is in open state or background. please give solution. #1136

Open Jeet007das opened 4 years ago

Jeet007das commented 4 years ago

Before openning an issue

  1. Reproduce it with the example project in this repo.
  2. If you can't receive iOS notification, make sure you can receive notification using quickstart-ios project provided by Firebase team

When openning an issue, please include following information for better support

  1. What version of RN and react-native-fcm are you running?
  2. What device are you using? (e.g iOS9 emulator, Android 6 device)?
  3. Is your app running in foreground, background or not running?
ersenkaya commented 3 years ago

use try/catch in finishNotificationResponse Method,

node_modules -> react-native-fcm->RNFIRMessagging.m

RCT_EXPORT_METHOD(finishNotificationResponse: (NSString )completionHandlerId){ RCTNotificationResponseCallback completionHandler = self.notificationCallbacks[completionHandlerId]; if (!completionHandler) { @try { RCTLogError(@"There is no completion handler with completionHandlerId: %@", completionHandlerId); return; } @catch (NSException e) { NSLog(@"Exception completionHandler: %@", e); }

} else {
    @try {
        completionHandler();
        [self.notificationCallbacks removeObjectForKey:completionHandlerId];
    }
    @catch (NSException * e) {
        NSLog(@"Exception completionHandler: %@", e);
    }
}

}