【发布时间】:2018-06-11 06:47:25
【问题描述】:
我是第一次使用 ionic 2 本地通知。我关注了这个YouTube tutorial。
当我在 Xcode 中测试我的应用时,我在下方收到一条警告消息,并且通知消息没有显示...不知道为什么。
警告:未知属性:在
我已经安装了
ionic cordova 插件添加 de.appplant.cordova.plugin.local-notification
npm install --save @ionic-native/local-notifications
并将插件作为提供程序添加到 src/app/app.module.ts
我有以下代码:
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' }
})
}
}
【问题讨论】:
标签: cordova ionic-framework ionic2