Open lfaz opened 6 years ago
We are in the same project with this error:
FATAL EXCEPTION: main
Process:xx.xxxx.xxxx, PID: 24776
java.lang.ClassCastException: xx.xxxx.xxxx.MainApplication cannot be cast to com.facebook.react.ReactApplication
at com.evollu.react.fcm.MessagingService$1.run(MessagingService.java:41)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
@MelissaWeng you are using exponent? Haven't figured out a way to coexist with exponent yet
@lulzimfazlija try leave your notification callback empty and see if it crashes
@evollu the app is detached from Expo and just only use ExpoKit to publish the app. And push notification works in the background, just crash the app when app is open and receiving the notification.
@MelissaWeng in that case check if logic in notification callback causes crash
@evollu Notification callback is left empty, but still app crashes in foreground (and works in background).
weird. can you provide an example repo? does the example project crash?
@evollu may I ask if you ever been able to make it work for android for both background and foreground? If so, can you prove some code of the MessageService.java also the MainApplication.java
@lulzimfazlija there is an example project in the repo
Hi, I just checked that my app targetSdkVersion = 26, and do you think it is the reason causing the crash? And how shall I proceed with it?
react-native itself targets 23. so to be safe use targetSdkVersion = 23
@evollu what do you think it is causing the crash on foreground?
Mainapplication.java looks as below:
// Needed for `react-native link`
public List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
// Add your own packages here!
// TODO: add cool native modules
// new MainReactPackage(),
new RNBackgroundGeolocation(),
// Needed for `react-native link`
new FIRMessagingPackage(),
//new RNBackgroundGeolocation(),
//new RNFirebasePackage(),
new VectorIconsPackage()
//new RNFirebaseMessagingPackage()
);
}
and notification handler, listener looks like:
`this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => { console.warn("listening.......................");
if (notif.fcm) {
console.log("sending notification...");
this.title = notif.fcm.title
this.body = notif.fcm.body
FCM.presentLocalNotification({
title: notif.title, // as FCM payload
body: notif.body, // as FCM payload (required)
priority: "high", // as FCM payload
click_action: "ACTION", // as FCM payload
auto_cancel: true, // Android only (default true)
vibrate: 300, // Android only default: 300, no vibration if you pass null
lights: true, // Android only, LED blinking (default false)
show_in_foreground: true, // show notification when app is in foreground (local & remote)
local: true
})
}
// optional, do some component related stuff
});`
ANy idea what would it cause the crash on foreground?
I still have the same issue!
i gave up using this library as it is enough crappy to waste your time, go and use onesignal, it is quite easy to setup and works like a charm for both platforms!
@lulzimfazlija @MelissaWeng Did you manage to get this working with ExpoKit? Yeah - OneSignal works great and it is easy to integrate but you "pay" in privacy... I managed to get the build work just fine but the app crashes on startup 😞
@nirpeled Did you check #813 ?
Tried multiple devices same it crashes, I am using react native 0.49, can receive notifications on background, but not when app is open! I am using "react-native-fcm": "^11.3.1" and using google services 11.8.0 on my app bundle!