It works when app is running in background and i click on received notification but not working when coldstart from received notification.
.
shared.LS.get('user').then((data: any) => {
if (!data) {
this.rootPage = AuthPage;
} else {
this.globalProvider.setAuthData(data);
this.rootPage = TabsPage;
}
});
platform.ready().then(() => {
if (platform.is('cordova')) {
this.oneSignal.startInit('**********', '*****************');
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
this.oneSignal.handleNotificationReceived().subscribe((data) => {
console.log(data);
});
this.oneSignal.handleNotificationOpened().subscribe((data) => {
console.log(data);
let type
try {
type = data.notification.payload.additionalData.type;
} catch (e) {
console.warn(e);
}
switch (type) {
case 'Followers': {
this.navController.push(UserProfilePage, {userId: data.notification.payload.additionalData.uid})
break;
}
}
});
this.oneSignal.endInit();
}