react-native-fcm: Crash with ExpoKit
Hi ! I encountered so much problems integrating this library with expokit, but now, i’m really close of it ! I don’t have any problems with iOS but Android drives me mad.
When I receive an notification on Android, it’ll instantly crash with this error
java.lang.NullPointerException: Attempt to invoke virtual method 'com.facebook.react.ReactInstanceManager com.facebook.react.ReactNativeHost.getReactInstanceManager()' on a null object reference
because of this line
ReactInstanceManager mReactInstanceManager = ((ReactApplication) getApplication()).getReactNativeHost().getReactInstanceManager();
My MainApplication class is like this:
package com.productinuse.preprod;
import android.support.multidex.MultiDexApplication;
import com.facebook.react.ReactPackage;
import java.util.Arrays;
import java.util.List;
import com.evollu.react.fcm.FIRMessagingPackage;
public class MainApplication extends MultiDexApplication {
public List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
// Add your own packages here!
new FIRMessagingPackage()
);
}
}
It doesn’t implement ReactApplication because of the ExpoKit implementation.
I already see this and this without any solutions
react-native-fcm: 7.5.1 expokit: sdk 19 @evollu I mention you because I’m really desperate aha 😉
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 15 (3 by maintainers)
For others trying to configure it, I got it to work by changing MessagingService:
last line changed to :
Where I added a method in MainActivity (which extends ExponentActivity) like:
Not sure if this can be be done with PR or not.
@amanforindia Can you please share the imports used in your snippet? Currently, it highlights
(MainActivity)Exponentin red for me, sayingunable to resolve symboltry if you can do it though some kind of reflection? I don’t know java much