WebAPI/SimplePush: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 3: Line 3:


partial interface Navigator {
partial interface Navigator {
   Push push;
   PushNotifications pushNotifications;
};
};


interface Push {
interface PushNotifications {


   // registers to receive push notifications for a given topic  
   // registers to receive push notifications for a given topic  
Line 25: Line 25:


   // this is the URL to which push notifications from the web application
   // this is the URL to which push notifications from the web application
   // must be sent to
   // must be sent to.
  // application should send this and pushRequestID as a pair to the
  // application server
   DOMString pushEndpoint;
   DOMString pushEndpoint;


Line 53: Line 55:


// all notifications will be sent to the system message handler.
// all notifications will be sent to the system message handler.
// which is up to the U/A to implement


navigator.mozSetMessageHandler("push", function(e) {
// apps can do something like
 
navigator.pushNotifications.onNotification = function(e) {
  // should this directly be e.topic, e.version?
   e.target.result.topic == This is the topic that is being observed
   e.target.result.topic == This is the topic that is being observed
   e.target.result.version == This is the current version for this topic
   e.target.result.version == This is the current version for this topic
Line 66: Line 70:
// topic of interest:
// topic of interest:


var req = navigator.push.register("topic");
var req = navigator.pushNotifications.register("topic");




// success callback
// success callback
req.onsuccess(e) = function() {
req.onsuccess(e) = function() {
 
  // post to application server
   e.target.result.pushEndpoint
   e.target.result.pushEndpoint
   e.target.result.pushRequestID
   e.target.result.pushRequestID
Line 80: Line 84:
// to unregister, you simply call..
// to unregister, you simply call..


req = navigator.push.unregister("topic");
req = navigator.pushNotifications.unregister("topic");
req.onsuccess() = function() {}
req.onsuccess() = function() {}
req.onerror() = function() {}
req.onerror() = function() {}
Line 116: Line 120:
Example:
Example:
<pre>
<pre>
   GET http://push.mozilla.org/register?key=<apikey>&pushRequestID=<pushRequestID>
   POST http://push.mozilla.org/register?key=<apikey>&pushRequestID=<pushRequestID>
</pre>
</pre>


Line 143: Line 147:
Example:
Example:
<pre>
<pre>
   GET http://push.mozilla.org/unregister?key=<apikey>&pushRequestID=<pushRequestID>
   POST http://push.mozilla.org/unregister?key=<apikey>&pushRequestID=<pushRequestID>
</pre>
</pre>


Line 173: Line 177:
Example:
Example:
<pre>
<pre>
   GET http://push.mozilla.org/unregister?key=<apikey>&pushRequestID=<pushRequestID>&version=<version>
   POST http://push.mozilla.org/update?key=<apikey>&pushRequestID=<pushRequestID>&version=<version>
</pre>
</pre>


Confirmed users
93

edits

Navigation menu