WebAPI/SimplePush
< WebAPI
Jump to navigation
Jump to search
// all notifications will be sent to the system message handler.
navigator.mozSetMessageHandler("push", function(e) {
e.target.result.topic == This is the topic that is being observed e.target.result.version == This is the current version for this topic
});
// to register to listen for a notification,
// you simply call push.register and pass an
// topic of interest:
var req = navigator.push.register("topic");
// success callback
req.onsuccess(e) = function() {
// url of the push server endpoint to // post new version number e.target.result.pushEndpoint
}
req.onerror() = function(e) {}
// to unregister, you simply call..
req = navigator.push.unregister("topic"); req.onsuccess() = function() {} req.onerror() = function() {}
// register() will send a request to the
// push server including:
application id making this request the string token that was passed into the register() call
user auth: TBD, but most probably headless browserid