-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crashing when app is closed, but with different error #51
Comments
I get this same error. The notification does appear, and can be clicked on. But the app crashes in the background. The result of this is that you cannot receive a follow up notification until the user launches/closes the app again. |
I didn't get this error, but I believe this is probably the same issue as the others are having. The way this lib is written, it's trying to instantiate the entire react app when receiving a background notification and some of the native modules (in my case FBSDK caused most of the issues) just won't instantiate nicely in this scenario for some reason. For most use cases, this is probably overkill. I ended up writing a very minimal background service that just shows the text of the notification via the react-native-system-notification lib and nothing more. This workaround may help you as well. First remove com.oney.gcm from this line in your Manifest:
Now add BackgroundService.java to your project:
|
Hmm, I think these may be different issues though. I have gotten other errors similar to #54. I had to rearrange my client entry js to ensure none of my App would be imported or registered if we were receiving a notification. Like this:
|
Re: build.gradle:
BackgroundService.java:
|
@stinju Can you elaborate a little more, I tried changing those but my build failed with |
@peterlazar1993 were you able to resolve your issue? Looks like your build wasn't compiling against an RN version with the new signatures. Check to see if the 'onHostPause' method is implemented in |
Did you resolve this already? How did you solve this issue? |
@jojonarte We decided to write a custom BackgroundService |
I resolved this error by creating a fork where removed not existing methods. And another thing is you should not require whole App while in background service, I'm not sure why, but maybe because some environment is not initialised. |
@vmakhaev What kind of background service did you write? Care to share? |
@peterlazar1993 I used the one from |
Comment the line. It should work. My index.android.js snippet: ` //GcmAndroid.stopService(); |
#22 also addressed by doing this change. |
@udfalkso Your solution works, but there's any way to make it show the message received by an external API instead of a static one?? |
@samcarlosimpres Yes. The code fetches the message from the notification, the static string there is just a fallback. For me the value is coming through in the "gcm.notification.body" key of the bundle, perhaps for you it is at another key.
|
guys, sorry. |
My app is also crashing @ RN 0.22.0 when app is killed, but I'm getting a different error:
I/ReactNativeJS(12477): 'GcmAndroid.launchNotification internal', undefined E/AndroidRuntime(12477): FATAL EXCEPTION: main E/AndroidRuntime(12477): Process: com.wayfarer, PID: 12477 E/AndroidRuntime(12477): java.lang.NoSuchMethodError: No virtual method onPause()V in class Lcom/facebook/react/ReactInstanceManager; or its super classes (declaration of 'com.facebook.react.ReactInstanceManager' appears in /data/app/com.wayfarer-2/base.apk) E/AndroidRuntime(12477): at com.oney.gcm.BackgroundService.onDestroy(BackgroundService.java:47) E/AndroidRuntime(12477): at android.app.ActivityThread.handleStopService(ActivityThread.java:3292) E/AndroidRuntime(12477): at android.app.ActivityThread.access$2300(ActivityThread.java:172) E/AndroidRuntime(12477): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1524) E/AndroidRuntime(12477): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime(12477): at android.os.Looper.loop(Looper.java:145) E/AndroidRuntime(12477): at android.app.ActivityThread.main(ActivityThread.java:5835) E/AndroidRuntime(12477): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(12477): at java.lang.reflect.Method.invoke(Method.java:372) E/AndroidRuntime(12477): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) E/AndroidRuntime(12477): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Any suggestions here? Thank you.
The text was updated successfully, but these errors were encountered: