Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥Library blocks all local notification opening events on iOS #3414

Closed
2 of 10 tasks
juhana opened this issue Apr 8, 2020 · 6 comments · Fixed by #3427
Closed
2 of 10 tasks

🔥Library blocks all local notification opening events on iOS #3414

juhana opened this issue Apr 8, 2020 · 6 comments · Fixed by #3427
Labels
plugin: messaging FCM only - ( messaging() ) - do not use for Notifications

Comments

@juhana
Copy link

juhana commented Apr 8, 2020

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:

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
NSDictionary *remoteNotification = response.notification.request.content.userInfo;
if (remoteNotification[@"gcm.message_id"]) {
NSDictionary *notificationDict = [RNFBMessagingSerializer remoteMessageUserInfoToDict:remoteNotification];
[[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_notification_opened" body:notificationDict];
_initialNotification = notificationDict;
completionHandler();
}
}

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
  • 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:
    • 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


@Ehesp
Copy link
Member

Ehesp commented Apr 8, 2020

Thanks for the detailed issue. We're tracking this on #3367 - we think we know what the issue is, just need to find some time to implement the fix!

@juhana
Copy link
Author

juhana commented Apr 8, 2020

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

@Ehesp Ehesp closed this as completed Apr 8, 2020
@Salakar Salakar added the plugin: messaging FCM only - ( messaging() ) - do not use for Notifications label Apr 9, 2020
@Salakar
Copy link
Contributor

Salakar commented Apr 9, 2020

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

@sivakumar-cf
Copy link

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

@Ehesp
Copy link
Member

Ehesp commented Apr 10, 2020

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

@sivakumar-cf
Copy link

@Ehesp Please check #3427 (comment)
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: messaging FCM only - ( messaging() ) - do not use for Notifications
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants