ionic3 本地通知

ionic cordova plugin add cordova-plugin-local-notification
npm install --save @ionic-native/local-notifications

检测是否有权限

 this.localNotifications.hasPermission().then(data=>{
        if(!data){
          this.localNotifications.requestPermission().then(data=>{
            console.log("data:"+data);
          })
        }
    })

自定义通知栏

  this.localNotifications.schedule({
      id: 1,
      title:result['memberName'],
      text: result['text'],
      sound: "",
      data: { groupId: result['groupId'],groupTitle:result['groupTitle'] },
      vibrate:true,
      wakeup:true,
    });

点击通知栏回调

 this.localNotifications.on('click').subscribe(result=>{
 });

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

你可能感兴趣的:(ionic3 本地通知)