离子2中的提醒/报警

rch*_*pta 2 android reminders cordova ionic-framework ionic2

我试图在一段时间后在ionic2中实现提醒/报警.我已经找到了这个插件https://github.com/wnyc/cordova-plugin-wakeuptimer但是我想用typescript 来实现它,因为这是无法识别的window.wakeuptimer在下面提到的代码中使用:

window.wakeuptimer.wakeup( successCallback,  
   errorCallback, 

   // a list of alarms to set

   {

        alarms : [{

            type : 'onetime',

            time : { hour : 14, minute : 30 },

            extra : { message : 'json containing app-specific information to be posted when alarm triggers' }, 

            message : 'Alarm has expired!'

       }] 

   }

); 
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我

Phi*_*tin 6

您尝试使用的插件已将近3年.比离子2本身更老.您应该查看https://ionicframework.com/docs/v2/native/中列出的本机插件

在过去,我使用Local Notifications插件(https://ionicframework.com/docs/v2/native/local-notifications/)来处理提醒/警报.

安排起来非常简单,您所要做的就是在您希望通知的时间创建一个Date对象.以下是使用您提供的数据的示例:

import { LocalNotifications } from 'ionic-native';


// Schedule delayed notification 

LocalNotifications.schedule({
   text: 'Alarm has expired!',
   at: new Date(new Date().getTime() + 3600),
   sound: isAndroid ? 'file://sound.mp3': 'file://beep.caf',
   data: { message : 'json containing app-specific information to be posted when alarm triggers' }
});
Run Code Online (Sandbox Code Playgroud)