Not quite sure why this is doing this only on Android, but its consistent. Otherwise, push notifications work great when app is closed or app is in foreground. Everything works perfectly on iOS too. Any ideas?
Are you using https://github.com/wix/react-native-navigation by any chance?
I'm having the same problem, everything works great when app is closed/foreground, but the app crash if it's already open in background and I open a notification. (I'm using react-native-navigation)
I don't have solution for you guys, I tried to bend over backwards making it work but I gave up. From what I understood this is one of the things "by design" for wix based on how they handle application views.
I am now using this package only for iOS and use react-native-firebase to send to Androids - that way I can leverage FCM at least. It's a shame though. I am kinda hoping wix navigation version 2 might have this resolved.
I had this problem and found out that if i receive a silent remote notification from my server then raise a localNotificationSchedule on the OnNotification event with date: new Date(Date.now()) my app doesnt crash.
I havent tested it much, just sharing what i found.
Do you have any other solution
Hello, not sure this will help you, but it might help others like me who find this post. I had the same problem: App crashes when touching the notification (only when the app was in background) and needed to be reinstalled to start at all again. First i thought i was re-registering (not properly unregistering) the broadcast receiver, but it turned out to be a workaround i put in a long time ago. Since some devices call the onCreate method again when resuming an activity, even though the app is still running in the background, i've added a static value that checks if the app is alive and prevents the redundant recreation. After removing this workaround the problem with the push crash was gone. However this doesn't resolve the issue with some devices stacking up MainActivities, but at least basic functionality is restored. Anyway, hope this helps (someone)..
Hey guys,
I'm using https://github.com/react-navigation/react-navigation (not Wix's navigation) and also having this issue, is this related in any way? The notification comes through just fine as long as the app is not active (even if working in the background) but will crash if the app is running and active.
Thanks!
Anyone? I still have this issue...=/
same issue ... using react-navigation... anyone got any fix?
Got same issue. My app were crashing ever time I get notification (either the app in foreground or in background).
Fixed by applying recommendations from this comment - https://github.com/zo0r/react-native-push-notification/issues/852#issuecomment-417641675
Nothing related to react-navigation in my case.
Same issue here, any info would be appreciated.
I'm using wix/react-native-navigation too.
I get this in Logcat:
```05-02 17:30:27.966 **** E/ReactNativeJS: Navigation.getRegisteredScreen: [object Object] used but not yet registered
05-02 17:30:28.029 **** E/unknown:ReactNative: Unable to launch redbox because react activity is not available, here is the error that redbox would've displayed: console.error: "Navigation.getRegisteredScreen: [object Object] used but not yet registered"
05-02 17:30:28.036 **** E/ReactNativeJS: Error while starting app: TypeError: undefined is not an object (evaluating 'Screen.navigatorButtons')
05-02 17:30:28.058 **** E/unknown:ReactNative: Unable to launch redbox because react activity is not available, here is the error that redbox would've displayed: console.error: "Error while starting app: TypeError: undefined is not an object (evaluating 'Screen.navigatorButtons')"
Aside from this case, the application loads properly.
I had to implement the workaround for wix/RNNavigation in App.js to avoid the application launching automatically upon receiving a notification and without user interaction, e.g.:
```if (Platform.OS === 'android') {
Navigation.isAppLaunched().then(appLaunched => {
if (appLaunched) {
startSingleScreenApp()
}
new NativeEventsReceiver().appLaunched(startSingleScreenApp) // App hasn't been launched yet -> show the UI only when needed.
})
} else {
startSingleScreenApp()
}
If you need additional information please let me know!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.
Most helpful comment
Same issue here, any info would be appreciated.
I'm using wix/react-native-navigation too.
I get this in Logcat:
```05-02 17:30:27.966 **** E/ReactNativeJS: Navigation.getRegisteredScreen: [object Object] used but not yet registered
05-02 17:30:28.029 **** E/unknown:ReactNative: Unable to launch redbox because react activity is not available, here is the error that redbox would've displayed: console.error: "Navigation.getRegisteredScreen: [object Object] used but not yet registered"
05-02 17:30:28.036 **** E/ReactNativeJS: Error while starting app: TypeError: undefined is not an object (evaluating 'Screen.navigatorButtons')
05-02 17:30:28.058 **** E/unknown:ReactNative: Unable to launch redbox because react activity is not available, here is the error that redbox would've displayed: console.error: "Error while starting app: TypeError: undefined is not an object (evaluating 'Screen.navigatorButtons')"
If you need additional information please let me know!