React-native-navigation: Prevent Android push notifications from relaunching app when closed

Created on 7 Feb 2018  路  3Comments  路  Source: wix/react-native-navigation

I'm working with a project that utilizes react-native-push-notification, and noticing an issue with Android, where the app will launch if it's closed when a notification gets received.

There had been some discussion here about switching over to react-native-notifications, https://github.com/wix/react-native-navigation/issues/566, but also a semi-discussed solution to work around the issue. We're already very much invested in this library so we don't want to switch over to the wix version.

Effectively, this is what I have come up with, but there's a missing piece to determine whether or not the code was called from a push notification.

index.android.js:

import { Navigation, NativeEventsReceiver } from 'react-native-navigation';
import { registerScreens } from './app/screens/registerScreens';
import logInNavigationConfig from './app/screens/logInNavigationConfig';

registerScreens();


function appOpenedFromPushNotification() {
    return false // ??? What goes here ???
}

Navigation.isAppLaunched()
  .then(appLaunched => {
    if (appLaunched || appOpenedFromPushNotification()) {
        startApp();
    } else {
        new NativeEventsReceiver().appLaunched(startApp());
    }

  });

function startApp() { // Start the app
    Navigation.startSingleScreenApp(logInNavigationConfig);

https://github.com/wix/react-native-navigation/issues/566#issuecomment-327404439 refers to appOpenedFromPushNotification(), but that was never actually discussed anywhere.

What am I missing?

馃彋 stale

All 3 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.

The issue has been closed for inactivity.

why would you close an issue for which there has not been an answer or a way to fix it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

kiroukou picture kiroukou  路  3Comments

yayanartha picture yayanartha  路  3Comments

henrikra picture henrikra  路  3Comments

EliSadaka picture EliSadaka  路  3Comments