[iOS] GIPReachability should be used from the main thread
react-native 0.35 iphone 5 iOS 10 simulator react-native-fcm 2.3.2
When I run the app, the following code crashes the app:
const FCM = require('react-native-fcm')
FCM.requestPermissions()
FCM.getFCMToken().then(()=>{})
FCM.on('notification', ()=>{})
FCM.on('refreshToken', ()=>{})
Xcode stops at the following line (ios/RNFIRMesssaging.m):
[[FIRMessaging messaging] setRemoteMessageDelegate:self];
And the log shows the following error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
GIPReachability should be used from the main thread
The error looks like in this issue: /firebase/quickstart-ios/issues/67.
I do not send anything with firebase console, the only thing I did was install react-native-fcm (npm), install Firebase/Messaging (pod) and include plist file from firebase console. Unfortunately my time on the mac os was limited, so I didn't manage to discover which method of require('react-native-fcm') exactly causes the crash.
By the way, that javascript works in android with the same package.json nicely. I mean, it doesn't crash.
Update. This is enough to cause the error:
const FCM = require('react-native-fcm')
FCM.requestPermissions()
I tried running second line both lately and in root scope of main js file. Doen't matter, still GIPReachability should be used from the main thread.
Sorry, accidentally closed =(
As in #169, messed up with code. It actually works.