Here is my code
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { OneSignal } from '@ionic-native/onesignal';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(private oneSignal: OneSignal,public navCtrl: NavController) {
this.oneSignal.startInit('5d4fd62b-b9f8-4e41-9a89-7ea3b18af3de','470761651487');
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.InAppAlert);
this.oneSignal.handleNotificationReceived().subscribe((d) => {
// do something when notification is received
console.log("NOTIFICATION RECEIVED");
console.log(d);
});
this.oneSignal.handleNotificationOpened().subscribe((d1) => {
// do something when a notification is opened
console.log("NOTIFICATOIN OPENED");
console.log(d1);
});
this.oneSignal.endInit();
}
}
I also import app module..