WebAPI/SimplePush: Difference between revisions

Line 77: Line 77:
   // you simply call push.register
   // you simply call push.register
   // Here, we'll register a channel for "email" updates. Channels can be for anything the app would like.</i>
   // Here, we'll register a channel for "email" updates. Channels can be for anything the app would like.</i>
   var reqEmail = navigator.pushNotifications.register();
   var reqEmail = navigator.pushNotification.register();
   reqEmail.onsuccess = function(e) {
   reqEmail.onsuccess = function(e) {
     emailEndpoint = e.target.result.pushEndpoint;
     emailEndpoint = e.target.result.pushEndpoint;
Line 85: Line 85:
   
   
   <i>// We'll also register a second channel for "im", because we're social and all about the socialists. Or something.</i>
   <i>// We'll also register a second channel for "im", because we're social and all about the socialists. Or something.</i>
   var reqIm = navigator.pushNotifications.register();
   var reqIm = navigator.pushNotification.register();
   reqIm.onsuccess = function(e) {
   reqIm.onsuccess = function(e) {
     imEndpoint = e.target.result.pushEndpoint;
     imEndpoint = e.target.result.pushEndpoint;
Line 110: Line 110:
  <i>// to unregister, you simply call..</i>
  <i>// to unregister, you simply call..</i>
  AppFramework.addEventListener('user-logout', function() {
  AppFramework.addEventListener('user-logout', function() {
   navigator.pushNotifications.unregister(emailEndpoint);
   navigator.pushNotification.unregister(emailEndpoint);
   navigator.pushNotifications.unregister(imEndpoint);
   navigator.pushNotification.unregister(imEndpoint);
  });
  });
   
   
Confirmed users
93

edits