Android 本地通知不起作用2
我正在尝试添加本地通知,但我不知道我的错误在哪里。没有错误,但当我在手机(android)上测试我的应用程序时,没有显示任何通知。以下是我的步骤: 1-安装Android 本地通知不起作用2,android,notifications,ionic2,local,Android,Notifications,Ionic2,Local,我正在尝试添加本地通知,但我不知道我的错误在哪里。没有错误,但当我在手机(android)上测试我的应用程序时,没有显示任何通知。以下是我的步骤: 1-安装 ionic plugin add de.appplant.cordova.plugin.local-notification npm install --save @ionic-native/local-notifications 2-app.module.ts import { LocalNotifications } from '@
ionic plugin add de.appplant.cordova.plugin.local-notification
npm install --save @ionic-native/local-notifications
2-app.module.ts
import { LocalNotifications } from '@ionic-native/local-notifications';
providers: [..., LocalNotifications]
3-
Home.ts
import { LocalNotifications } from '@ionic-native/local-notifications';
constructor(..., public localNotifications: LocalNotifications) {}
schedule() {
let date= new Date(new Date().getTime() + 5 * 1000);
alert("Your notification will be shown at " + date);
this.localNotifications.schedule({
id: 1,
title: "Test Title",
text: "Delayed Notification",
at: date,
//sound: null,
//every: 'week'
});
}
Home.html
<button ion-button full (click)="schedule()">test notification</button>
测试通知
通过将本地通知插件的名称添加到“config.xml”解决的问题通过将本地通知插件的名称添加到“config.xml”解决的问题