本地通知不起作用离子2

时间:2017-10-28 06:51:26

标签: 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-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>

1 个答案:

答案 0 :(得分:2)

通过将本地通知插件的名称添加到&#34; config.xml&#34;

来解决问题