OLD | NEW |
---|---|
(Empty) | |
1 <html> | |
Peter Beverloo
2014/10/20 12:45:22
Carry-forward since you did not reply.
=====
nit
Michael van Ouwerkerk
2014/10/20 15:30:37
Done.
| |
2 <head> | |
3 <title>Push API</title> | |
Peter Beverloo
2014/10/20 12:45:22
Carry-forward since you did not reply.
=====
mic
Michael van Ouwerkerk
2014/10/20 15:30:37
It's a test, so I marked it as such now. Not sure
| |
4 <script> | |
5 function sendResultToTest(result) { | |
6 console.log(result); | |
7 if (window.domAutomationController) { | |
8 domAutomationController.send('' + result); | |
9 } | |
10 } | |
11 | |
12 function sendErrorToTest(error) { | |
13 sendResultToTest(error.name + ' - ' + error.message); | |
14 } | |
15 | |
16 function registerServiceWorker() { | |
17 navigator.serviceWorker.register('sw.js').then(function(swRegistration) { | |
18 console.log(swRegistration); | |
19 sendResultToTest('ok'); | |
20 }, sendErrorToTest); | |
21 } | |
22 | |
23 function registerPush(senderId) { | |
24 navigator.serviceWorker.ready.then(function() { | |
25 navigator.push.register(senderId).then(function(pushRegistration) { | |
26 sendResultToTest(pushRegistration.pushEndpoint + ' - ' + pushRegistrat ion.pushRegistrationId); | |
27 }, sendErrorToTest); | |
28 }, sendErrorToTest); | |
29 } | |
30 </script> | |
31 </head> | |
32 <body>Push API</body> | |
33 </html> | |
OLD | NEW |