WebAPI/SimplePush: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Created page with "// 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...")
 
No edit summary
Line 1: Line 1:
<code>
// all notifications will be sent to the system message handler.
// all notifications will be sent to the system message handler.


Line 41: Line 43:


user auth:  TBD, but most probably headless browserid
user auth:  TBD, but most probably headless browserid
</code>

Revision as of 23:25, 1 November 2012

// 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