diff --git a/src/screens/root/container/rootContainer.js b/src/screens/root/container/rootContainer.js index ae6dff4ea..89581c8af 100644 --- a/src/screens/root/container/rootContainer.js +++ b/src/screens/root/container/rootContainer.js @@ -161,20 +161,35 @@ const RootContainer = () => (WrappedComponent) => { _createPushListener = () => { const { navigation } = this.props; + let params = null; + let key = null; + let routeName = null; Push.setListener({ onPushNotificationReceived(pushNotification) { - if (AppState.currentState === 'background') { - if (pushNotification.customProperties.routeName) { - navigation.navigate({ - routeName: pushNotification.customProperties.routeName, - }); - } else { - navigation.navigate({ - routeName: ROUTES.TABBAR.NOTIFICATION, - }); - } + const extra = JSON.parse(pushNotification.customProperties.extra); + + if (extra.parent_permlink || extra.permlink) { + params = { + author: + extra.parent_permlink + ? extra.parent_author + : pushNotification.customProperties.target, + permlink: extra.parent_permlink ? extra.parent_permlink : extra.permlink, + }; + key = extra.parent_permlink ? extra.parent_permlink : extra.permlink; + routeName = ROUTES.SCREENS.POST; + } else { + params = { + username: pushNotification.customProperties.source, + }; + key = pushNotification.customProperties.source; + routeName = ROUTES.SCREENS.PROFILE; } + + setTimeout(() => { + navigation.navigate({ routeName, params, key }); + }, 4000); }, }); };