Closed imanshul closed 6 months ago
Very unexpected. So those lines are where we call the original notification handler delegate - if you receive a message and there was a messaging delegate configured before firebase
the original delegate is saved here, during RNFBMessaging setup:
The best thing I can think of is that WebEngage (which can apparently do mobile push notification things...) is installing a delegate, and somewhere between iOS notification center, react-native-firebase code and WebEngage code there is an issue with the typing of the message received or the message receiver. [1]
No one else has posted a crash like this before and I believe our code is just a) saving the original delegate, b) sending the original message to the original delegate so I think react-native-firebase is doing things correctly here but the problem is in the "forwarding code" which we saved and are calling.
What happens if you take out WebEngage temporarily as a test?
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Getting Fatal Exception: NSInvalidArgumentException -[NSObject userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:]: unrecognized selector sent to instance 0x280653020 in same behaviour .
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Issue
When notification is received and app is in foreground the app crashes. The app also crashes when in background state and clicked on notification in iOS. Another problem is the listener for background/foreground message receiver are also not invoking for iOS as mentioned in rnfirebase documentation.
The stack trace when app is in foreground and app crashes:
Project Files
Javascript
Click To Expand
#### `package.json`: ```json "@react-native-firebase/analytics": "^18.7.3", "@react-native-firebase/app": "^18.7.3", "@react-native-firebase/crashlytics": "^18.7.3", "@react-native-firebase/messaging": "^18.7.3", ``` #### `firebase.json` for react-native-firebase v6: ```json { "react-native": { "messaging_android_notification_channel_id": "high-priority", "messaging_ios_auto_register_for_remote_messages": true } } ```
iOS
Click To Expand
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # Resolve react_native_pods.rb with node to allow for hoisting # ----- Uncomment below code, if removing the react-naitve-permissions ---- # require Pod::Executable.execute_command('node', ['-p', # 'require.resolve( # "react-native/scripts/react_native_pods.rb", # {paths: [process.argv[1]]}, # )', __dir__]).strip # ------ Start Used for react-native-permissions -------- def node_require(script) # Resolve script with node to allow for hoisting require Pod::Executable.execute_command('node', ['-p', "require.resolve( '#{script}', {paths: [process.argv[1]]}, )", __dir__]).strip end node_require('react-native/scripts/react_native_pods.rb') node_require('react-native-permissions/scripts/setup.rb') # ------ END Used for react-native-permissions -------- platform :ios, min_ios_version_supported prepare_react_native_project! # ------ Start Used for react-native-permissions -------- # ⬇️ uncomment wanted permissions setup_permissions([ # 'AppTrackingTransparency', # 'Bluetooth', # 'Calendars', # 'CalendarsWriteOnly', 'Camera', # 'Contacts', # 'FaceID', # 'LocationAccuracy', # 'LocationAlways', # 'LocationWhenInUse', # 'MediaLibrary', # 'Microphone', # 'Motion', # 'Notifications', 'PhotoLibrary', # 'PhotoLibraryAddOnly', # 'Reminders', # 'Siri', # 'SpeechRecognition', # 'StoreKit', ]) # ------ END Used for react-native-permissions -------- # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded # # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` # ```js # module.exports = { # dependencies: { # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), # ``` flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.disabled linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end target 'App13Karat' do pod 'WebEngage' config = use_native_modules! use_frameworks! :linkage => :static $RNFirebaseAsStaticFramework = true use_react_native!( :path => config[:reactNativePath], # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. :flipper_configuration => flipper_config, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) target 'App13KaratTests' do inherit! :complete # Pods for testing end # ServiceExtension Target target 'NotificationService' do platform :ios, min_ios_version_supported pod 'WebEngageBannerPush' end # ContentExtension Target target 'NotificationViewController' do platform :ios, min_ios_version_supported pod 'WebEngageAppEx/ContentExtension' end post_install do |installer| # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 react_native_post_install( installer, config[:reactNativePath], :mac_catalyst_enabled => false ) workAroundForSharedApplication(installer) end end # Fix for MMKV after adding WebEngage, especially NotificationService and NotificationViewController as App Extension def workAroundForSharedApplication(installer) installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No' end end end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import
#import
#import
#import
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleName = @"App13Karat";
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
// Add me --- \/
[FIRApp configure];
// Add me --- /\
//Start WebEngage
[[WebEngage sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
//End WebEngage
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [self getBundleURL];
}
- (NSURL *)getBundleURL
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [CodePush bundleURL];
#endif
}
@end
```
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`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```
Environment
Click To Expand
**`react-native info` output:** ``` System: OS: macOS 14.1.2 CPU: (8) arm64 Apple M1 Memory: 58.31 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.16.1 path: ~/.nvm/versions/node/v18.16.1/bin/node Yarn: version: 1.22.17 path: /usr/local/bin/yarn npm: version: 9.5.1 path: ~/.nvm/versions/node/v18.16.1/bin/npm Watchman: version: 2023.12.04.00 path: /usr/local/bin/watchman Managers: CocoaPods: version: 1.14.3 path: /usr/local/bin/pod SDKs: iOS SDK: Platforms: - DriverKit 23.0 - iOS 17.0 - macOS 14.0 - tvOS 17.0 - watchOS 10.0 Android SDK: API Levels: - "17" - "23" - "27" - "28" - "29" - "30" - "31" - "33" - "34" Build Tools: - 29.0.2 - 30.0.0 - 30.0.1 - 30.0.2 - 30.0.3 - 31.0.0 - 33.0.0 - 33.0.1 - 34.0.0 System Images: - android-26 | Google APIs ARM 64 v8a - android-28 | Google ARM64-V8a Play ARM 64 v8a - android-29 | Google Play ARM 64 v8a - android-30 | Google APIs ARM 64 v8a - android-31 | Google APIs ARM 64 v8a - android-32 | Google Play ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2023.1 AI-231.9392.1.2311.11076708 Xcode: version: 15.0.1/15A507 path: /usr/bin/xcodebuild Languages: Java: version: 11.0.11 path: /usr/bin/javac Ruby: version: 2.6.10 path: /usr/bin/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.73.1 wanted: 0.73.1 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false ``` - **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:** - `18.7.3` - **`Firebase` module(s) you're using that has the issue:** - `10.19.0` - **Are you using `TypeScript`?** - `N`
React Native Firebase
andInvertase
on Twitter for updates on the library.