Search code examples
iosfirebasereact-nativetypeerrortestflight

TypeError undefined is not an object (evaluating 'e.props.onChangeToken')


I have an react-native app which runs fine in xCode (both in simulator and on iPhone). However when uploaded to TestFlight and installed through TestFlight the app crashes when first started. When you then open the app again it runs fine.

I use Bugsnag to get error reports from the app after released to TestFlight. The error I receive in Bugsnag when the app crashes is:

TypeError undefined is not an object (evaluating 'e.props.onChangeToken')

And the stacktrace:

main.jsbundle:518:677 
main.jsbundle:37:1281 value
main.jsbundle:18:2853 value
main.jsbundle:18:280 
main.jsbundle:18:2304 value
main.jsbundle:18:252 callFunctionReturnFlushedQueue

However this does not tell me much ...

I suspect that it might be connected to Firebase since around when the app crashes I:

  • login to Firebase with:

firebase.auth().signInWithEmailAndPassword(email, password)

  • request initial notification:

FCM.getInitialNotification().then(notif => { this.setState({ initNotif: notif });

  • request permission for notifications:

FCM.requestPermissions({ badge: false, sound: true, alert: true });

However I'm not sure. Has anyone ever received a similar error message?

EDIT Found one (!) other case of the same error in a comment to the article here: https://blog.botreetechnologies.com/how-to-send-push-notification-to-the-android-phones-using-react-native-and-fcm-b28e1746da7b

This implies that it could be related to FCM...


Solution

  • Turns out that the error was caused by the fact that I called:

    FCM.getInitialNotification().then(notif => { this.setState({ initNotif: notif });
    

    Before requesting permission for sending notifications... :

    FCM.requestPermissions({ badge: false, sound: true, alert: true });