I am trying to figure out how to send a push notification to the user when someone likes a post. I am using ionic & firebase and I can't seem to figure this out. I am a novice to this.

I've added the init code to my app.js as shown below. Can anyone let me know what I need to do to parse in the user who like the post and inform the user who created the post.

.run(function ($ionicPlatform, $ionicScrollDelegate, $cordovaNetwork, $ionicPopup, $cordovaCamera, $rootScope, $state, $location, $timeout, User, LOCATIONS) {

///////////////////////////// VARIABLES ////////////////////////////////////////
$rootScope.$state = $state;

function initPushwoosh() {
  var pushNotification = cordova.require("com.pushwoosh.plugins.pushwoosh.PushNotification");

  //set push notification callback before we initialize the plugin
  document.addEventListener('push-notification', function(event) {
    var notification = event.notification;
    var customAttributes = notification.aps;
    if (customAttributes['route']) {
      var route = customAttributes['route'];
      $state.go(route.path, route.params);
    }
    alert(notification.aps.alert);
    pushNotification.setApplicationIconBadgeNumber(0);
  });

  //initialize the plugin
  pushNotification.onDeviceReady({pw_appid:"8398B-636DE"});

  //register for pushes
  pushNotification.registerDevice(
    function(status) {
      var deviceToken = status['deviceToken'];
      $rootScope.deviceToken = deviceToken;
      console.warn('registerDevice: ' + deviceToken);
    },
    function(status) {
      console.warn('failed to register : ' + JSON.stringify(status));
      alert(JSON.stringify(['failed to register ', status]));
    }
  );

  //reset badges on app start
  pushNotification.setApplicationIconBadgeNumber(0);
}

$ionicPlatform.ready(function () {
  initPushwoosh();

});

});

asked 21 Jan '16, 17:14
nareeboy's gravatar image

nareeboy
111

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×445
×39
×18

question asked: 21 Jan '16, 17:14

question was seen: 869 times

last updated: 21 Jan '16, 17:14