Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to execute a specific function when alarm wake up ? #25

Open
watio opened this issue Feb 23, 2017 · 0 comments
Open

how to execute a specific function when alarm wake up ? #25

watio opened this issue Feb 23, 2017 · 0 comments

Comments

@watio
Copy link

watio commented Feb 23, 2017

Hello,
tank you for this plugin.
i would like to now how to execute a specific function when alarm wakeup.
exemple: i would like to execute my function test when alarm wake up but it don't work.
can you help me please?
this ismy code:

function alarm(date, heure, min){

	var successCallback = function(result) {
		if (result.type==='wakeup') {
			test();
			//console.log('wakeup alarm detected--' + result.extra);

		} else if(result.type==='set'){
			alert('alarm initialiser');
			//console.log('wakeup alarm set--' + result);
		}else{
			alert('unkown');
			
		}
	};

	var errorCallback = function(result) {
		
		if (result.type==='wakeup') {
			console.log('wakeup alarm detected--' + result.extra);
		} else if(result.type==='set'){
			console.log('wakeup alarm set--' + result);
		} else {
			console.log('wakeup unhandled type (' + result.type + ')');
		}
	};

	// //type : 'onetime',

		window.wakeuptimer.wakeup(successCallback,
			errorCallback,
			{
				alarms: [{
					type: 'onetime',
					time: {hour: heure, minute: min},
					extra: { message: 'test'},
					message: 'Alarm has expired!'
				}]
			}
		);

		
}

function test(){
alert('it is time');
}

tank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant