react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

🔥Library blocks all local notification opening events on iOS

Open juhana opened this issue 6 years ago • 6 comments

Issue

React Native Firebase reacts to opening the app through a Cloud Messaging notification by triggering the onNotificationOpenedApp event. On iOS when creating a local notification using a third party library and opening the app by tapping on it, react-native-firebase blocks the event from reaching the third party library and no event is triggered, either by this library or the one that created the alert.

There's a warning in the XCode console that's related:

UNUserNotificationCenter delegate received call to -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: but the completion handler was never called.

The Objective-C code that blocks the event is this: https://github.com/invertase/react-native-firebase/blob/d66a6118f82005087f53b86571990fc071402153/packages/messaging/ios/RNFBMessaging/RNFBMessaging%2BUNUserNotificationCenter.m#L70-L78

I don't know much about how iOS handles events but apparently this method overrides its third-party library counterparts, and because this handler only does anything with notifications coming from Cloud Messaging, it effectively blocks handling all other notification types. Optimally this would somehow tell UNUserNotificationCenter to move on to the other handlers but I don't know how that would be done or if it's even possible.

Another solution would be to let onNotificationOpenedApp handle all notifications and e.g. add a flag that tells whether it's a local notification or a Cloud Messaging notification.


Project Files

Javascript

Click To Expand

package.json:

# N/A

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • [ ] I'm not using Pods
  • [x] I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A


Android

Click To Expand

Have you converted to AndroidX?

  • [ ] my application is an AndroidX application?
  • [ ] I am using android/gradle.settings jetifier=true for Android compatibility?
  • [ ] I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

N/A

  • Platform that you're experiencing the issue on:
    • [x] iOS
    • [ ] Android
    • [ ] iOS but have not tested behavior on Android
    • [ ] Android but have not tested behavior on iOS
    • [ ] Both
  • react-native-firebase version you're using that has this issue:
    • 6.4.0
  • Firebase module(s) you're using that has the issue:
    • messaging
  • Are you using TypeScript?
    • N/A


juhana avatar Apr 08 '20 06:04 juhana

Thanks for the detailed issue. We're tracking this on https://github.com/invertase/react-native-firebase/issues/3367 - we think we know what the issue is, just need to find some time to implement the fix!

Ehesp avatar Apr 08 '20 07:04 Ehesp

Thanks, sounds good! Sorry about the duplicate, feel free to close this one.

juhana avatar Apr 08 '20 07:04 juhana

Please try 6.4.1-alpha.0 from NPM - this should fix the issues - PR: #3427

Salakar avatar Apr 09 '20 14:04 Salakar

Tried to use this PR. Still, I am not getting the AppDelegate willPresentNotification or didReceiveNotificationResponse callbacks. I am using version 6.4.1-alpha.0 @Salakar

sivakumar-cf avatar Apr 10 '20 17:04 sivakumar-cf

Posting your AppDelegates is the only way we can help here. We need to see what's not being forwarded.

Ehesp avatar Apr 10 '20 17:04 Ehesp

@Ehesp Please check https://github.com/invertase/react-native-firebase/pull/3427#issuecomment-612169375 I got callbacks on swizzled methods in Native CloudMessaging package classes but it is not being forwarded to AppDelegate original callbacks. So eventually I cannot track or add custom notification handlers.

sivakumar-cf avatar Apr 13 '20 05:04 sivakumar-cf