Hello everyone. I use OneSignal as a service for Push notifications. Strange thing happens when app is in foreground mode. Default alert box with incoming Push notification appears if I disabled it previously by running:
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
So this is what happens: When I launch app for the first time from Xcode, everything works well. Alert box doesn’t appear when notification is received and handleNotificationReceived
is called, what is expected.
When I close the app and open it again, if I send new notification, alert box will appear and call handleNotificationReceived
and handleNotificationOpened
what is not expected at all because I disabled alert when calling this line of code:
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
So the app works well only once, when opened for the first time after fresh installation through Xcode.
Here is the code I call on every app startup, in app.component.ts:
initializePushNotifs() {
this.oneSignal.startInit('0000', '0000');
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
this.oneSignal.handleNotificationReceived().subscribe(data => {
this.presentNoConnectionAlert('Received', 'Received', 'Received');
});
this.oneSignal.handleNotificationOpened().subscribe(data => {
this.presentNoConnectionAlert('Opened', 'Opened', 'Opened');
});
this.oneSignal.endInit();
}
Anyone knows or can point out what is the issue.
Thanks in advance