Ali H
Ali H

Reputation: 923

Local notification not working ionic 2

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>

Upvotes: 0

Views: 541

Answers (1)

Ali H
Ali H

Reputation: 923

The problem solved by adding the name of local notification plugin to "config.xml"

Upvotes: 2

Related Questions