wnyc / cordova-plugin-wakeuptimer

Cordova plugin for a wakeup alarm clock
90 stars 111 forks source link

Using ionic2 #18

Open Olexiy665 opened 8 years ago

Olexiy665 commented 8 years ago

Hi, how can I use this awesome plugin in the ionic 2 typescript application?

evandrojr commented 7 years ago

+1

EltonFaust commented 7 years ago

Hello, I've not tested this plugin yet, but you can try:

ionic plugin add https://github.com/wnyc/cordova-plugin-wakeuptimer.git

on your ts file, add before class definition

declare var window;

and on you class you can do something like

...
public initializeAlarms(): void {
    window.wakeuptimer.wakeup(
        () => {
            console.log("success callback")
        },
        () => {
            console.log("error callback")
        }, 
        // a list of alarms to set
        {
            alarms : [
                {
                    type : "onetime",
                    time : { hour : 14, minute : 30 },
                    extra : { message : "Lorem ipsum" }, 
                    message : "Alarm has expired!"
                }
            ] 
        }
    );
}
...

hope i helped :)

polisettyManoj commented 6 years ago

i tried your approach @EltonFaust , but its giving the following error.

Unhandled promise rejection (rejection id: 1): CordovaError: Failed to fetch plugin https://github.com/wnyc/cordova-plugin-wakeuptimer.git via registry. Probably this is either a connection problem, or plugin spec is incorrect

can you help me regarding this??

Thanks in Advance :)

EltonFaust commented 6 years ago

Hello,

which node/npm version are you using?

the newer versions of npm requires a package.json file (npm 6 and newer i guess), something that old packages doesnt contains, that is probabily the reason of this error,

i've forked this project and made some changes, if you like, you could opt to add mine instead,

cordova plugin add https://github.com/EltonFaust/cordova-plugin-wakeuptimer.git
polisettyManoj commented 6 years ago

Thank you @EltonFaust :) I will try your plugin