Merge pull request #585 from esteemapp/enhancement/#466

fix for #466
This commit is contained in:
uğur erdal 2019-02-14 11:25:51 +03:00 committed by GitHub
commit d2f0ec40d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,
});
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 {
navigation.navigate({
routeName: ROUTES.TABBAR.NOTIFICATION,
});
}
params = {
username: pushNotification.customProperties.source,
};
key = pushNotification.customProperties.source;
routeName = ROUTES.SCREENS.PROFILE;
}
setTimeout(() => {
navigation.navigate({ routeName, params, key });
}, 4000);
},
});
};