WebAPI/SimplePush: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 45: Line 45:
user auth:  TBD, but most probably headless browserid
user auth:  TBD, but most probably headless browserid


</pre>
<pre>
    +---------------+                +-----------------+              +------------------+
    |  Browser    |                |  Push Server  |              |    App Server    |
    +------+--------+                +--------+--------+              +---------+--------+
          |          register()              |                                |
          +---------------------------------->|                                |
          |                                  |                                |
          |          ok                      |                                |
          |<---------------------------------+|                                |
          |                                  |                                |
          |          register successful    |                                |
          |+------------------------------------------------------------------->|
          |                                  |                                |
          |                                  |        Update                  |
          |                                  | <-------------------------------+
          |                                  |        Update                  |
          |                                  | <-------------------------------+
          |          update                  |                                |
          |<----------------------------------+                                |
          |                                  |                                |
          |                                  |                                |
          |                                  |                                |
          |                                  |                                |
          |                                  |                                |
          |                                  |                                |
          |                                  |                                |
          |                                  |                                |
          |                                  |                                |
</pre>
</pre>

Revision as of 22:03, 2 November 2012

Client Side API


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




    +---------------+                 +-----------------+              +------------------+
    |   Browser     |                 |   Push Server   |              |    App Server    |
    +------+--------+                 +--------+--------+              +---------+--------+
           |           register()              |                                 |
           +---------------------------------->|                                 |
           |                                   |                                 |
           |           ok                      |                                 |
           |<---------------------------------+|                                 |
           |                                   |                                 |
           |           register successful     |                                 |
           |+------------------------------------------------------------------->|
           |                                   |                                 |
           |                                   |        Update                   |
           |                                   | <-------------------------------+
           |                                   |        Update                   |
           |                                   | <-------------------------------+
           |           update                  |                                 |
           |<----------------------------------+                                 |
           |                                   |                                 |
           |                                   |                                 |
           |                                   |                                 |
           |                                   |                                 |
           |                                   |                                 |
           |                                   |                                 |
           |                                   |                                 |
           |                                   |                                 |
           |                                   |                                 |