I'm working with ionic 2 local notification for the first time. I've followed this YouTube tutorial.
When I test my app in Xcode, I'm getting a warning message below and the notification message doesn't show... not sure why.
WARN: Unknown property: at
I have installed
ionic cordova plugin add de.appplant.cordova.plugin.local-notification
npm install --save @ionic-native/local-notifications
and added the plugin as a provider in src/app/app.module.ts
I have following code:
home.html:
<button ion-button (click)=myNotifications()>Test</button>
app.module.ts
import { Component } from '@angular/core';
import { NavController, Platform, ActionSheetController, AlertController } from 'ionic-angular';
import { ScreenOrientation } from '@ionic-native/screen-orientation';
import { LocalNotifications } from '@ionic-native/local-notifications';
export class HomePage {
constructor(public navCtrl: NavController,
public platform: Platform,
private screenOrientation: ScreenOrientation,
private localNotifications: LocalNotifications,
public alertCtrl: AlertController ) {
this.platform.ready().then((ready) =>{
this.localNotifications.on('click', (notification, state) => {
let json = JSON.parse(notification.data);
let alert = this.alertCtrl.create({
title: notification.title,
message: json.fullMsq
});
alert.present();
});
});
}
myNotifications() {
this.localNotifications.schedule({
id: 1,
title: 'ABC Meeting Notification',
text: 'ABC Meeting will start in 20 mins',
at: new Date(new Date().getTime() + 20*60*1000),
data: { fullMsq: 'this is the full notification message' }
})
}
}