メインコンテンツまでスキップ
Version: v6

Local Notifications

This plugin allows you to display local notifications on the device

https://github.com/katzer/cordova-plugin-local-notifications

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Installation

$ npm install cordova-plugin-local-notification 
$ npm install @awesome-cordova-plugins/local-notifications
$ ionic cap sync

Supported Platforms

  • Android
  • iOS
  • Windows

Usage

React

Learn more about using Ionic Native components in React

Angular

import { LocalNotifications } from '@awesome-cordova-plugins/local-notifications/ngx';


constructor(private localNotifications: LocalNotifications) { }

...


// Schedule a single notification
this.localNotifications.schedule({
id: 1,
text: 'Single ILocalNotification',
sound: isAndroid? 'file://sound.mp3': 'file://beep.caf',
data: { secret: key }
});


// Schedule multiple notifications
this.localNotifications.schedule([{
id: 1,
text: 'Multi ILocalNotification 1',
sound: isAndroid ? 'file://sound.mp3': 'file://beep.caf',
data: { secret:key }
},{
id: 2,
title: 'Local ILocalNotification Example',
text: 'Multi ILocalNotification 2',
icon: 'http://example.com/icon.png'
}]);


// Schedule delayed notification
this.localNotifications.schedule({
text: 'Delayed ILocalNotification',
trigger: {at: new Date(new Date().getTime() + 3600)},
led: 'FF0000',
sound: null
});