OneSignal handleNotificationReceived() not working on receiving notification


#1

Hello!
Just added OneSignal to my app and it’s working fine both IOS and Android but handleNotificationReceived() just doesn’t do anything (console is blank). Do you know what it might be? Here’s the code:

OneSignal.startInit(“myAppId”, “someOtherIdForGoogle”);
OneSignal.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification);
OneSignal.iOSSettings({kOSSettingsKeyAutoPrompt: true, kOSSettingsKeyInAppLaunchURL: true});

OneSignal.handleNotificationReceived()
.subscribe(
data => {
console.log(‘NOTIFICATION RECEIVED!’);
this.notificationReceivedCallback(data);
},
error => {
console.error(error);
}
);

OneSignal.handleNotificationOpened()
.subscribe(
data => {
console.log(‘NOTIFICATION OPENED!’);
this.notificationOpenedCallback(data);
},
error => {
console.error(error);
}
);

OneSignal.endInit();

OneSignal.getIds()
.then(
data => {
this.config.setOneSignalIds(data);
console.log("OneSignal Ids: " + JSON.stringify(data))
}
)


#2

UPDATE: handleNotificationReceived() is working when the APP is active