Advertisement
sombriks

sample push notification on client side (cordova)

Mar 5th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ...
  2.  
  3.  
  4. //
  5. // push plugin
  6. document.addEventListener("deviceready", function(){
  7.   var push = PushNotification.init({
  8.     "android": {"senderID": "NUMERO DO SENDER ID"},
  9.     "ios": {"alert": "true", "badge": "true", "sound": "true"},
  10.     "windows": {}
  11.   });
  12.   push.on('registration', function(data) {
  13.     setTimeout(function(){
  14.       angular.element(document.body).scope().regtoken(data);
  15.     },3000);
  16.   });
  17.   push.on('notification', function(data) {
  18.     console.debug(data);
  19.     // data.message,
  20.     // data.title,
  21.     // data.count,
  22.     // data.sound,
  23.     // data.image,
  24.     // data.additionalData
  25.     // setTimeout(function(){
  26.       angular.element(document.body).scope().incrNotif();
  27.     // },3000);
  28.    });
  29. });
  30.  
  31. document.addEventListener('deviceready', function () {
  32.   if (navigator.notification) { // Override default HTML alert with native dialog
  33.       window.alert = function (message) {
  34.           navigator.notification.alert(
  35.               message,    // message
  36.               null,       // callback
  37.               "Ambbi app", // title
  38.               'OK'        // buttonName
  39.           );
  40.       };
  41.   }
  42. }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement