Skip to content

Instantly share code, notes, and snippets.

@chikoski
Created June 29, 2014 07:33
Show Gist options
  • Select an option

  • Save chikoski/142d67564b6672b7202c to your computer and use it in GitHub Desktop.

Select an option

Save chikoski/142d67564b6672b7202c to your computer and use it in GitHub Desktop.
alarmtest.app
(function(){
document.querySelector("#start").addEventListener("click", function(event){
var now = new Date();
var due = new Date(now.valueOf() + 10000);
console.log("now = " + now);
console.log("due = " + due);
navigator.mozSetMessageHandler("alarm", function (message) {
console.log("alarm fired");
});
console.log(navigator.mozSetMessageHandler);
console.log(navigator.mozAlarms);
var request = navigator.mozAlarms.add(due, "honorTimezone");
request.onsuccess = function(event){
console.log(event);
};
console.log("alarm request = " + request);
console.log(navigator.mozAlarms.getAll());
});
})();
<!doctype html>
<html lang="ja">
<head>
<title>alarm test</title>
<meta charset="utf-8">
</head>
<body>
<button id="start">スタート</button>
<script src="app.js"></script>
</body>
</html>
{
"name": "test app",
"description": "test alarm",
"launch_path": "/index.html",
"permissions": {
"alarms": {
"description": "set alarm"
}
},
"messages": [
{ "alarm": "/index.html" }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment