Before the IOS 14.2 update, firebase push notifications when received and tapped on by the user would correctly open the app, whether it was in foreground or background.
However, we've been receiving issues in production mode, when the push notification is received, it no longer opens the app.
It is currently working fine in development however.
The error that is logged is NSInternalInconsistencyException Call must be made on main thread
Click To Expand
#### `package.json`:
"@react-native-firebase/analytics": "^6.2.0",
"@react-native-firebase/app": "^6.2.0",
"@react-native-firebase/messaging": "^6.2.0"
#### `firebase.json` for react-native-firebase v6:
# N/A
### iOS
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:
platform :ios, '11.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native-unimodules/cocoapods'
target 'jupiter' do
# Pods for jupiter
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
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'
pod 'RNInputMask', :path => '../node_modules/react-native-text-input-mask/ios/InputMask'
pod 'GoogleIDFASupport', '~> 3.14.0'
use_unimodules!
use_native_modules!
end
#### `AppDelegate.m`:
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "AppDelegate.h"
#import <Firebase.h>
#import <RNBranch/RNBranch.h>
#import "RNNotifications.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNSplashScreen.h"
#import <React/RCTLinkingManager.h>
#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
@implementation AppDelegate
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
[RNNotifications startMonitorNotifications];
// Uncomment for test mode
// [RNBranch useTestInstance];
[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"jupiter" initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[super application:application didFinishLaunchingWithOptions:launchOptions];
[RNSplashScreen show];
return YES;
}
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
// You can inject any extra modules that you would like here, more information at:
// https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection
return extraModules;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
if (![RNBranch.branch application:app openURL:url options:options]) {
if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
return YES;
}
return [RCTLinkingManager application:app openURL:url options:options];
}
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
[RNNotifications didFailToRegisterForRemoteNotificationsWithError:error];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
return [RNBranch continueUserActivity:userActivity];
}
@end
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 -->
Click To Expand
**`react-native info` output:**
System:
OS: macOS 11.0
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 84.14 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 12.16.0 - ~/.nvm/versions/node/v12.16.0/bin/node
Yarn: 1.19.2 - /usr/local/bin/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v12.16.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 14.2, DriverKit 20.0, macOS 11.0, tvOS 14.2, watchOS 7.1
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 12.2/12B45b - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
- **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:**
- `e.g. 6.2.0`
6.2.0
- **`Firebase` module(s) you're using that has the issue:**
- `e.g. Instance ID`
- **Are you using `TypeScript`?**
- `Y/N` & `VERSION`
N
React Native Firebase and Invertase on Twitter for updates on the library.Hi there! Can you please post the full stack trace? Also, have you checked the issues list in firebase-ios-sdk repo (also here on github) to see if it's deeper - in the google sdk - or here (the stack trace might also help point the way...)
Same here. I am trying to migrate to v10 from v5 to see if it helps
@hahtml Let me know if upgrading the versions help!
We've just started encountering this with local notifications after upgrading RN from 0.61.5 to 0.63.3 and Xcode from 11 to 12.2.
We're still on react-native-firebase 5.5.6 currently (due to needing to migrate notifications to something else). Under the older versions of RN and Xcode, we didn't get the crash.
Here's the stack trace: https://gist.github.com/liamjones/bc22538569cb716dc1f4d94c369aa654
As a quick fix I can wrap the completionHandler() call (https://github.com/invertase/react-native-firebase/blob/v5.5.6/ios/RNFirebase/notifications/RNFirebaseNotifications.m#L113) in a dispatch to the main thread and then it's happy.
If this is an appropriate fix does it need to be synchronous or can it be async without causing issues?
I found out the culprit for us was coming from react-native-notifications library which we use in conjunction with Firebase v6. Upgrading the library to the latest version helped, and as @liamjones mentioned the call was wrapped to run on main thread asynchronously.
Hello,
Same issue goes for me.
On iOS 14.2, when the user click sur PUSH notification, app is crashing.
Thanks,
To date, no one has followed my request for info:
Hi there! Can you please post the full stack trace? Also, have you checked the issues list in firebase-ios-sdk repo (also here on github) to see if it's deeper - in the google sdk - or here (the stack trace might also help point the way...)
Additional steps that are relevant in the last 20 days that my request for info has been ignored:
Please note that I do not reproduce though. I do not think this is a react-native-firebase problem.
Further comments saying "me too" without providing any details or taking any effort to advance the discussion are worse than useless, they waste all subscribers time here. Don't do that please.
Hi @mikehardy, I posted a full stack trace in the gist above (https://gist.github.com/liamjones/bc22538569cb716dc1f4d94c369aa654). I haven't had a chance to check the firebase-ios-sdk repo yet. This _is_ under an older SDK though, we're still on react-native-firebase 5.5.6 as mentioned above (and using the Firebase SDK versions specified in the legacy install instructions)
You posted a stack vs v5 right? If so, I have disregarded it. Current versions only
Facing the same issue with react-native-firebase 5.6.0 and tested on iOS 14.2
here attached the stacktrace.

I am honestly shocked anyone would be attempting to deploy react-native-firebase v5.x at this point.
In strong terms I actively discourage it. You don't have access with that code base to the newer versions of the underlying firebase SDKs, and they make changes needed to adapt to the changing mobile ecosystem represented by Android 10/11 and iOS14
There will be nothing but discouragement for using v5 here, no support - with apologies, but it's a real thing: it's time to upgrade
Hi. @mikehardy ,
have applied a patch (the first answer of this stackoverflow issue https://stackoverflow.com/questions/64565093/exception-call-must-be-made-on-main-thread-ios ) using patch-package https://github.com/ds300/patch-package that fix the bug for now.
but yes, we are planing to upgrade to v6 soon.
thanks for you reply.
I am of course glad it's working for you :-) - I maintain things because I love hearing success stories and getting things fixed, but yes :pray: please upgrade :-)