react-native-fcm icon indicating copy to clipboard operation
react-native-fcm copied to clipboard

[iOS] GIPReachability should be used from the main thread

Open frmrgr opened this issue 10 years ago • 3 comments

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.

frmrgr avatar Nov 02 '16 01:11 frmrgr

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.

frmrgr avatar Nov 03 '16 16:11 frmrgr

Sorry, accidentally closed =(

frmrgr avatar Nov 03 '16 16:11 frmrgr

As in #169, messed up with code. It actually works.

frmrgr avatar Nov 03 '16 20:11 frmrgr