"permissions": {
"browser":{},
"systemXHR":{},
"settings":{ "access": "readonly" },
"geolocation" : {},
"storage": {},
"desktop-notification" : {},
"device-storage:pictures" : { "access": "readwrite" },
"device-storage:videos" : { "access": "readwrite" },
"device-storage:music" : { "access": "readwrite" }
}
"messages": [
{ "notification": "/index.html" }
]
window.navigator.mozSetMessageHandler('notification',
this.onNotification.bind(this));
}
+--------+ +--------+ +--------+ +--------+
| webapp | | user | | push | | app |
| | | agent | | server | | server |
+--------+ +--------+ +--------+ +--------+
| | | |
|-----register------>| | |
| | | |
| (user accepts) | |
| | | |
| |<-setup push service->| |
| | | |
|<---success---------| | |
| | | |
|<--activate service with PushService attributes----------------->|
| | | |
| | |<--push notification-|
| | | per service API |
| | | |
| | (match to user agent) |
| | | |
| |<--push notification--| |
| | per service protocol | |
| | | |
| (match to webapp) | |
| | | |
|<---system message--| | |
| | | |
"permissions": {
"push": {}
},
"messages": {
"push": "/index.html" }
if (!navigator.push) {
alert('Sorry push not supported');
return;
}
var request = navigator.push.register();
request.onsuccess = function onSuccess() { ... };
request.onerror = function onError(e) { ... };
request.onsuccess = function onSuccess() {
var endPoint = request.result;
// ... now we have a way to be notified
}
curl -X PUT --data 'version=<version_number>' '<end point we got>'
window.navigator.setMessageHandler('push', function onPushNotification(evt) {
var endpoint = evt.pushEndpoint;
var version = evt.version;
.... do your magic ....
});