_checkNotification = () => {
OneSignal.setNotificationWillShowInForegroundHandler(notificationReceivedEvent => {
// console.log("OneSignal: notification will show in foreground:", notificationReceivedEvent);
let notification = notificationReceivedEvent.getNotification();
// console.log("notification: ", notification);
const data = notification.additionalData
if (data.response.type === 'normal notification') {
console.log('normal notification', this.context.normalCount)
this.context.NormalCountData(this.context.normalCount + 1)
} else {
this.context.MessageCountData(this.context.MessageCount + 1)
}
console.log("additionalData: ", JSON.stringify(data.response.type));
// Complete with null means don't show a notification.
notificationReceivedEvent.complete(notification);
});
//Method for handling notifications opened
OneSignal.setNotificationOpenedHandler(notification => {
if (this.context.MessageCount > 0) {
this.context.MessageCountData(this.context.MessageCount - 1)
}else {
this.context.NormalCountData(this.context.normalCount - 1)
}
// console.log("OneSignal: notification opened:", notification);
});
}