Hi,
I am trying to install one signal push notifications with the plugin written on the documentation but I have tried many different solutions to install it but it seems not works with Ionic + Vue.js.
After I have installed the plugin with Capacitor, one of the solutions was to insert the code in the App main component like this:
created() {
if (this.loggedUser) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const $vm = this
setInterval(() => $vm.getUnreadNotifications(), 5000);
}
this.handlerNotifications();
},
watch: {
queryField: function () {
this.searchFriend()
}
},
methods: {
handlerNotifications() {
OneSignal.startInit('XXXXXX', 'XXXXX');
OneSignal.handleNotificationOpened()
.subscribe(async jsonData => {
const confirmAlert = await alertController
.create({
header: jsonData.notification.payload.title,
message: jsonData.notification.payload.body,
buttons: ['OK']
});
confirmAlert.present();
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
});
OneSignal.endInit();
},
Nothing happens on Android Emulator and the code does not enter in OneSignal.handleNotificationOpened().subscribe method.