Skip to content

🔥 RNFirebaseMessaging is intercepting FCM delegate call #1814

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

Closed
6 of 31 tasks
littlehome-eugene opened this issue Jan 9, 2019 · 3 comments · Fixed by #3339
Closed
6 of 31 tasks

🔥 RNFirebaseMessaging is intercepting FCM delegate call #1814

littlehome-eugene opened this issue Jan 9, 2019 · 3 comments · Fixed by #3339
Labels
Keep Open avoids the stale bot plugin: messaging FCM only - ( messaging() ) - do not use for Notifications

Comments

@littlehome-eugene
Copy link

We are using FCM and expect the following function to be called

`AppDelegate's

  • (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {`

However RNFirebaseMessaging.m 's same function (signature) gets called instead

When we shake device and reload the js, RNFirebaseMessaging.m 's init method gets called and it is setting the delegate to itself.

When we run the app by running it from xcode, this sometimes happens and sometimes doesn't..
There's no explicit code to call RNFirebaseMessaging's init anywhere in our code. (We want our AppDelegate to be the delegate of the FCM messaging ..

Issue


Project Files

iOS

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
platform :ios, '9.0'
 use_frameworks!
 target "littlehome" do
   rn_maps_path = '../node_modules/react-native-maps'

   pod 'React', :path => '../node_modules/react-native', :subspecs => [
     'Core',
     'RCTText',
     'RCTImage',
     'RCTNetwork',
     'RCTSettings',
     'RCTLinkingIOS',
     'DevSupport',
     'RCTAnimation',
     'RCTWebSocket', # needed for localhost testing of your app
     'CxxBridge',
     #'BatchedBridge',
     'RCTGeolocation'
     # Add any other subspecs you want to use in your project
   ]
   pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
   pod 'Firebase', '4.11.0'
   pod 'Firebase/Core', '4.11.0'
   pod 'Firebase/Messaging', '4.11.0'
   pod 'Firebase/DynamicLinks', '4.11.0'
   pod 'Firebase/AdMob', '4.11.0'
   pod 'Firebase/RemoteConfig', '4.11.0'

   pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
   pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
   pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
   #---https://github.com/facebook/react-native/issues/20031 end//

   # react-native-maps dependencies
   pod 'react-native-maps', path: rn_maps_path
   # pod 'react-native-google-maps', path: rn_maps_path  # Remove this line if you don't want to support GoogleMaps on iOS
   # https://github.com/react-community/react-native-maps/issues/1582
   pod 'GoogleMaps'  # Remove this line if you don't want to support GoogleMaps on iOS
   # pod 'Google-Maps-iOS-Utils' # Remove this line if you don't want to support GoogleMaps on iOS
   # https://github.com/googlemaps/google-maps-ios-utils/blob/master/Swift.md

   pod 'SentryReactNative', :path => '../node_modules/react-native-sentry'
   pod 'BugsnagReactNative', :path => '../node_modules/bugsnag-react-native'

   pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'

 end


 post_install do |installer|
   installer.pods_project.targets.each do |target|
       if target.name == 'yoga'
           target.build_configurations.each do |config|
               config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO'
               config.build_settings['GCC_WARN_64_TO_32_BIT_CONVERSION'] = 'NO'
           end
       end

     target.build_configurations.each do |config|
       config.build_settings['SWIFT_VERSION'] = '3.0'
     end
   end
 end


 pre_install do |installer|
   # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
   Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
 end

 # [!] [Xcodeproj] Generated duplicate UUIDs:
 # https://github.com/CocoaPods/CocoaPods/issues/4370
 install! 'cocoapods',
          :deterministic_uuids => false

AppDelegate.m:

   [FIRApp configure];

   // fcm
   [FIRMessaging messaging].delegate = self;

   if ([UNUserNotificationCenter class] != nil) {
     // iOS 10 or later
     // For iOS 10 display notification (sent via APNS)
     [UNUserNotificationCenter currentNotificationCenter].delegate = self;
     UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
       UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
     [[UNUserNotificationCenter currentNotificationCenter]
       requestAuthorizationWithOptions:authOptions
                     completionHandler:^(BOOL granted, NSError * _Nullable error) {
         // ...
       }];
   } else {
     // iOS 10 notifications aren't available; fall back to iOS 8-9 notifications.
     UIUserNotificationType allNotificationTypes =
       (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
     UIUserNotificationSettings *settings =
       [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
     [application registerUserNotificationSettings:settings];
   }

   [application registerForRemoteNotifications];
   // fcm

Android

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

  • 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
  • If known, the version of the platform are you experiencing the issue on:
    • ADD_SOMETHING_HERE e.g. iOS 10 or Android API 28
  • Operating System:
    • MacOS, version: N/A
    • Windows, version: N/A
    • Other, please specify: N/A
  • Build Tools:
    • Xcode 10.1
  • React Native version:
    • 0.57.4
  • React Native Firebase library version:
    • 5.1.0
  • Firebase module(s) you're using that has the issue:
    • N/A
    • Authentication
    • Analytics
    • Cloud Firestore
    • Cloud Messaging (FCM)
    • Crashlytics
    • Dynamic Links
    • Functions Callable
    • Invites
    • Instance ID
    • Notifications
    • Performance Monitoring
    • Realtime Database
    • Remote Config
    • Storage
  • Are you using TypeScript?
    • No
    • Yes, version: N/A
  • Are you using Expo, e.g. ExpoKit?
    • No
    • Yes, I've not ejected
    • Yes, but I have ejected to ExpoKit
    • Yes, but I have ejected to vanilla React Native
    • Expo version: N/A

Think react-native-firebase is great? Please consider supporting the project with any of the below:

@littlehome-eugene littlehome-eugene changed the title 🔥 RNFirebaseMessaging is intercepting FCM delegate call (:fire:) RNFirebaseMessaging is intercepting FCM delegate call Jan 9, 2019
@littlehome-eugene littlehome-eugene changed the title (:fire:) RNFirebaseMessaging is intercepting FCM delegate call 🔥 RNFirebaseMessaging is intercepting FCM delegate call Jan 9, 2019
@Salakar Salakar added this to the v6.0.0 milestone Jan 9, 2019
@Salakar Salakar added plugin: messaging FCM only - ( messaging() ) - do not use for Notifications Keep Open avoids the stale bot labels Jan 9, 2019
@manurana
Copy link

If I understand correctly, this is preventing the integration of any other service that sends its own messages to the app. For us, the particular service is CleverTap. The app is not able to show any CleverTap initiated messages.
Would love to see this resolved sooner rather than later.
One implementation could be how Segment has done it.

@Salakar
Copy link
Contributor

Salakar commented Jan 29, 2019

I'll look at adding something for this in v6, we could probably use introspection to determine if the method is configured in your AppDelegate and call it from RNFB messaging - so that both continue to work.

@Salakar
Copy link
Contributor

Salakar commented Mar 24, 2020

Hey, I've pushed up something for this in 0b052d6 - simply implementing the FIRMessagingDelegate methods in your AppDelegate will now allow them to be called (you don't need to set [FIRMessaging messaging].delegate). This will land as part of PR #3339

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

Successfully merging a pull request may close this issue.

3 participants