Scheduling a native alarm/timer

I'm working on a cookbook app where one of the features should be alarms/timers for each ingredient/step. (I'm using Ionic, a JavaScript framework for running PWA as a native app install. It's based on a wrapper around Apache Cordova.)

I've probably got 90% of the way done, and suddenly I'm realizing, I'm not sure if it's possible to schedule an alarm/timer on the device from Ionic.

Local notifications could work, I've been experimenting with it, but it's just a notification... I haven't found a way to keep them notifying continuously until dismissed. (Is there a way?)

Push notifications could work, but I get the feeling that would be a lot of non-ideal overhead. And it's still just a notification.

Is there any way, with Ionic / Cordova / Capacitor / anything, to schedule an alarm/timer in the same way a normal user would?

Do apps have permissions for setting an alarm?

Or is this just not possible?

1 answer

  • answered 2019-09-10 08:54 Melvita

    You need an alarm plugin. this one can work:

    to set an alarm :

    // set wakeup timer
    window.wakeuptimer.wakeup( successCallback,
       // 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!'