Using getInitialNotification() makes my app crash on iOS whenever I opened the app by tapping on a displayed local notification.
The following steps lead to a crash for me:
let n = new firebase.notifications.Notification();
n.setNotificationId("test").setBody("test").setTitle("test");
firebase.notifications().displayNotification(n);
firebase.notifications().getInitialNotification();
Exception '*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil' was thrown while invoking complete on target RNFirebaseNotifications with params (
"<null>",
1
)
callstack: (
0 CoreFoundation 0x00000001036ce29b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000101d83735 objc_exception_throw + 48
2 CoreFoundation 0x00000001036188fc _CFThrowFormattedException + 194
3 CoreFoundation 0x000000010374080c -[__NSDictionaryM setObject:forKeyedSubscript:] + 1036
4 appname 0x0000000100787d2b -[RNFirebaseNotifications complete:fetchResult:] + 139
5 CoreFoundation 0x00000001036d511c __invoking___ + 140
6 CoreFoundation 0x00000001036d25b5 -[NSInvocation invoke] + 325
7 CoreFoundation 0x00000001036d2a06 -[NSInvocation invokeWithTarget:] + 54
8 appname 0x00000001004b67da -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2810
9 appname 0x0000000100571816 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 790
10 appname 0x000000010057132f _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
11 appname 0x00000001005712a9 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
12 libdispatch.dylib 0x000000010652a51d _dispatch_call_block_and_release + 12
13 libdispatch.dylib 0x000000010652b587 _dispatch_client_callout + 8
14 libdispatch.dylib 0x0000000106532058 _dispatch_lane_serial_drain + 720
15 libdispatch.dylib 0x0000000106532b9b _dispatch_lane_invoke + 401
16 libdispatch.dylib 0x000000010653b9c6 _dispatch_workloop_worker_thread + 645
17 libsystem_pthread.dylib 0x0000000106910fd2 _pthread_wqthread + 980
18 libsystem_pthread.dylib 0x0000000106910be9 start_wqthread + 13
)
RCTFatal
facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&)
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_lane_serial_drain
_dispatch_lane_invoke
_dispatch_workloop_worker_thread
_pthread_wqthread
start_wqthread
React Native
version: 0.57.1React Native Firebase
Version: 5.0.0Firebase
Module: notificationstypescript
? yesI've got this in production. Any idea for a workaround?
We have this in production too, using RNFirebase 5.0.0.
Am debugging this today, will report back with a fix shortly hopefully.
I have same issue. Have any suggest to fix it quickly?
@sinhpn92 am working on it, unfortunately my testing phone (iPhone 5s) has finally died today 馃槴 so this is making life a bit difficult testing some stuff that can't be tested on the simulator.
I'm also getting this on simulator.
Right, I have a fix, will push up to master for the v5.1.0 release, short term partial (stops crashes) workaround is to put a if (handlerKey != nil) { }
around the following lines: https://github.com/invertase/react-native-firebase/blob/master/ios/RNFirebase/notifications/RNFirebaseNotifications.m#L102-L107
Commit above for reference.
@fliPmitKlammern @dluksza @pehagg @sinhpn92 I've published an RC for v5.1.0 if you'd like to try this out without fiddling with code in node_modules
:
yarn add [email protected]
Minor
versioned release to update firebase sdks, for now see the /tests app in the project for a reference of SDK versions (check build.gradle/podfile etc)
Thanks again for the report.
Loving react-native-firebase
and the support we provide? Please consider supporting us with any of the below:
React Native Firebase
and Invertase
on Twitter Having the same issue using:
"@react-native-firebase/app": "^6.0.3",
"@react-native-firebase/auth": "^6.0.3",
-> the code:
export const useAuth = (authInstance) => {
const [authState, setState] = React.useState({
isLoading: true,
user: null,
})
React.useEffect(() => {
const unsubscribe = authInstance.onAuthStateChanged(user => {
setState({ isLoading: false, user })
if (user) {
Purchases.setDebugLogsEnabled(true)
Purchases.setup(secrets.PurchaseToken, user.uid)
}
})
return unsubscribe
}, [authInstance])
return authState
}
-> produces:
Exception '* -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil' was thrown while invoking addAuthStateListener on target RNFBAuthModule with params (
"[DEFAULT]"
)
callstack: (
0 CoreFoundation 0x000000010f6be02e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x000000010f226b20 objc_exception_throw + 48
2 CoreFoundation 0x000000010f750a71 _CFThrowFormattedException + 194
3 CoreFoundation 0x000000010f75b6b3 -[__NSDictionaryM setObject:forKeyedSubscript:].cold.1 + 35
4 CoreFoundation 0x000000010f71f160 -[__NSDictionaryM setObject:forKeyedSubscript:] + 1088
5 pSUS 0x0000000104d751b2 -[RNFBAuthModule addAuthStateListener:] + 498
6 CoreFoundation 0x000000010f6c51cc __invoking___ + 140
7 CoreFoundation 0x000000010f6c22df -[NSInvocation invoke] + 319
8 CoreFoundation 0x000000010f6c27e4 -[NSInvocation invokeWithTarget:] + 68
9 pSUS 0x0000000104e74252 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2658
10 pSUS 0x0000000104e78387 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 791
11 pSUS 0x0000000104e77e93 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 131
12 pSUS 0x0000000104e77e09 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
13 libdispatch.dylib 0x000000011096b848 _dispatch_call_block_and_release + 12
14 libdispatch.dylib 0x000000011096c7b9 _dispatch_client_callout + 8
15 libdispatch.dylib 0x0000000110972526 _dispatch_lane_serial_drain + 707
16 libdispatch.dylib 0x0000000110972f5c _dispatch_lane_invoke + 388
17 libdispatch.dylib 0x000000011097cff9 _dispatch_workloop_worker_thread + 626
18 libsystem_pthread.dylib 0x0000000110de0763 _pthread_wqthread + 290
19 libsystem_pthread.dylib 0x0000000110de05c3 start_wqthread + 15
)
RCTFatal
facebook::react::invokeInner(RCTBridge, RCTModuleData, unsigned int, folly::dynamic const&)
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_lane_serial_drain
_dispatch_lane_invoke
_dispatch_workloop_worker_thread
_pthread_wqthread
start_wqthread
I've got this issue as well when trying to use two different firebase apps in my project. :(
in the index of my code the following line was commented:
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => NotificationHandler);
the Notification handler is the function bellow:
const NotificationHandler = async (message) => {
console.warn('RNFirebaseBackgroundMessage: ', message);
return Promise.resolve();
};
This resolved the problem in my case
Most helpful comment
I've got this issue as well when trying to use two different firebase apps in my project. :(