I'm trying to add local notifications but I don't know where is my mistake. There are no errors but when I tested my app on mobile (android), then no notification shown. Here are my steps:
1- Installation
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”来解决问题
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.