{"action":"closed","issue":{"url":"https://api.github.com/repos/wix/react-native-navigation/issues/2741","repository_url":"https://api.github.com/repos/wix/react-native-navigation","labels_url":"https://api.github.com/repos/wix/react-native-navigation/issues/2741/labels{/name}","comments_url":"https://api.github.com/repos/wix/react-native-navigation/issues/2741/comments","events_url":"https://api.github.com/repos/wix/react-native-navigation/issues/2741/events","html_url":"https://github.com/wix/react-native-navigation/issues/2741","id":297946848,"node_id":"MDU6SXNzdWUyOTc5NDY4NDg=","number":2741,"title":"App stuck on white screen when launched from deep link while in background (android)","user":{"login":"ThomasDelteil","id":3716307,"node_id":"MDQ6VXNlcjM3MTYzMDc=","avatar_url":"https://avatars2.githubusercontent.com/u/3716307?v=4","gravatar_id":"","url":"https://api.github.com/users/ThomasDelteil","html_url":"https://github.com/ThomasDelteil","followers_url":"https://api.github.com/users/ThomasDelteil/followers","following_url":"https://api.github.com/users/ThomasDelteil/following{/other_user}","gists_url":"https://api.github.com/users/ThomasDelteil/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasDelteil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasDelteil/subscriptions","organizations_url":"https://api.github.com/users/ThomasDelteil/orgs","repos_url":"https://api.github.com/users/ThomasDelteil/repos","events_url":"https://api.github.com/users/ThomasDelteil/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasDelteil/received_events","type":"User","site_admin":false},"labels":[{"id":951487479,"node_id":"MDU6TGFiZWw5NTE0ODc0Nzk=","url":"https://api.github.com/repos/wix/react-native-navigation/labels/%F0%9F%8F%9A%20stale","name":"🏚 stale","color":"e6e6e6","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-02-16T23:03:50Z","updated_at":"2018-06-09T06:42:15Z","closed_at":"2018-06-09T06:42:15Z","author_association":"NONE","body":"### Issue Description\r\n\r\nWhen deep linking into the app, while the app is in background, from an external link using a custom scheme a la `myapp://` the app is stuck on a blank screen on Android. It works fine on iOS, both from background and first launch. Android works fine for first launch.\r\n\r\nI found somewhat similar issues reported several time, I tried a patchwork of the proposed fixes, none of them worked.\r\n\r\nIf someone knows what is happening in the lifecycle of the android activity when coming back from background that would cause such issue, that would be nice.\r\n\r\n### Steps to Reproduce / Code Snippets / Screenshots\r\n\r\nCode is as follows: \r\n\r\n`app.android.tsx`\r\n```ts\r\nimport React from 'react'; // eslint-disable-line\r\nimport AppState from 'react-native';\r\nimport { Provider } from 'react-redux';\r\nimport { Navigation, NativeEventsReceiver } from 'react-native-navigation';\r\nimport { compose, createStore } from 'redux';\r\nimport rootReducer from './redux';\r\n\r\nimport { registerScreens, registerScreenVisibilityListener, tabs, navigatorStyle } from './views';\r\n\r\nconst store = compose()(createStore)(rootReducer);\r\nregisterScreens(store, Provider);\r\nregisterScreenVisibilityListener();\r\n\r\nfunction startApp() {\r\n    Navigation.startSingleScreenApp({\r\n        screen: {\r\n            screen: 'app.home',\r\n            title: 'Home',\r\n            navigatorStyle,\r\n            leftButtons: [\r\n                {\r\n                    id: 'sideMenu'\r\n                }\r\n            ]\r\n        },\r\n        drawer: {\r\n            left: {\r\n                screen: 'app.drawer'\r\n            }\r\n        }\r\n    });\r\n    \r\n}\r\n\r\nNavigation.isAppLaunched()\r\n    .then(appLaunched => {\r\n        if (appLaunched) {\r\n            startApp(); // App is launched -> show UI\r\n        }\r\n        new NativeEventsReceiver().appLaunched(startApp); // App hasn't been launched yet -> show the UI only when needed.\r\n    });\r\n```\r\n\r\nrelevant part of base Component class inherited by all the screens, including Home:\r\n```tsx\r\nconstructor(props) {\r\n    super(props);\r\n    this._handleOpenURL = this._handleOpenURL.bind(this);\r\n    this._checkDeepLink = this._checkDeepLink.bind(this);\r\n    this._navigateToScreenAndroid = this._navigateToScreenAndroid.bind(this);\r\n    this._handleAppStateChange = this._handleAppStateChange.bind(this);\r\n}\r\n\r\ncomponentDidMount() {\r\n    AppState.addEventListener('change', this._handleAppStateChange);\r\n    Linking.addEventListener('url', this._handleOpenURL);\r\n}\r\n\r\ncomponentWillUnmount() {\r\n    AppState.removeEventListener('change', this._handleAppStateChange);\r\n    Linking.removeEventListener('url', this._handleOpenURL);\r\n}\r\n\r\n_handleAppStateChange(currentAppState) {\r\n    if (currentAppState == 'active') {\r\n        Linking.getInitialURL().then(url => this._checkDeepLink(url));\r\n    }\r\n}\r\n\r\n_handleOpenURL(event) {\r\n    this._checkDeepLink(event.url);\r\n}\r\n\r\n_checkDeepLink(url) {\r\n    if (url) {\r\n        var parts = url.split('myapp://myhost.com/')\r\n        if (parts.length > 0) {\r\n            var target = parts[1];\r\n            this._navigateToScreenAndroid(target);\r\n        }\r\n    }\r\n}\r\n\r\n_navigateToScreenAndroid(screen) {\r\n    this.props.navigator.resetTo({\r\n        screen: 'app.'+screen,\r\n        title: screen,\r\n        navigatorStyle,\r\n        animated: true,\r\n        animationType: 'fade',\r\n        leftButtons: [\r\n            {\r\n                id: 'sideMenu'\r\n            }\r\n        ]\r\n    });\r\n}\r\n\r\n```\r\n\r\nThe android-logs show that, after clicking on a deep-link in the browser:\r\n```\r\n02-16 15:00:53.102 22518 22518 D ReactNative: ReactInstanceManager.detachViewFromInstance()\r\n02-16 15:00:53.102 22518 22518 D ReactNative: ReactInstanceManager.detachViewFromInstance()\r\n02-16 15:00:53.102 22518 22518 D ReactNative: CatalystInstanceImpl.destroy() start\r\n02-16 15:00:53.139 22518 22518 D ReactNative: ReactInstanceManager.ctor()\r\n02-16 15:00:53.172 22518 22518 D ReactNative: ReactInstanceManager.createReactContextInBackground()\r\n02-16 15:00:53.172 22518 22518 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()\r\n02-16 15:00:53.172 22518 22518 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()\r\n02-16 15:00:53.172 22518 22518 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()\r\n02-16 15:00:53.173 22518 22518 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()\r\n02-16 15:00:53.188 22518 22532 D ReactNative: CatalystInstanceImpl.destroy() end\r\n02-16 15:00:53.194 22518 22564 D ReactNative: ReactInstanceManager.createReactContext()\r\n02-16 15:00:53.247 22518 22564 D ReactNative: Initializing React Xplat Bridge.\r\n02-16 15:00:53.248 22518 22564 D ReactNative: Initializing React Xplat Bridge before initializeBridge\r\n02-16 15:00:53.256 22518 22564 D ReactNative: Initializing React Xplat Bridge after initializeBridge\r\n02-16 15:00:53.256 22518 22564 D ReactNative: CatalystInstanceImpl.runJSBundle()\r\n02-16 15:00:53.257 22518 22567 D ReactNative: ReactInstanceManager.setupReactContext()\r\n02-16 15:00:53.257 22518 22567 D ReactNative: CatalystInstanceImpl.initialize()\r\n02-16 15:00:53.273 22518 22518 D ReactNative: CatalystInstanceImpl.destroy() start\r\n02-16 15:00:53.550 22518 22541 D ReactNative: CatalystInstanceImpl.destroy() end\r\n```\r\n\r\n---\r\n### Environment\r\n* React Native Navigation version: 1.1.378\r\n* React Native version: 0.53.0\r\n* Platform(s) (iOS, Android, or both?): android\r\n* Device info (Simulator/Device? OS version? Debug/Release?): Simulator / Debug\r\n"}}
{"actor":{"display_login":"stale"}}