Local Notifications

Contents

This plugin allows you to display local notifications on the device

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

联系我们?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.

Contact Us Today!

Ionic 本地通知Local Notifications插件的安装(Installation)

ionic cordova plugin add cordova-plugin-local-notification npm install @ionic-native/local-notifications
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEY npm install @ionic-enterprise/local-notifications

Ionic 本地通知Local Notifications插件支持的平台(Supported Platforms)

  • Android
  • iOS
  • Windows

Ionic 本地通知Local Notifications插件的用法(Usage)

import { LocalNotifications } from '@ionic-native/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
});