-1

I am using parse to send push notifications and my mobile app is based out of Ionic(angularjs). I am currently sending push notifications through channels. If I want to open specific page when user clicks on notification, how do I do? My current code is

window.parsePlugin.initialize('waDzmmDVt7hNmRCoY50wOFN3lsRoW2xu42WrPYLs', 'IF2RHNA0slYDq8feUhweewmcK2uEnOqDnK8J7jUf', function() {
  console.log('Parse initialized successfully.');

  window.parsePlugin.subscribe('SampleChannel', function() {
    console.log('Successfully subscribed to SampleChannel.');

      window.parsePlugin.getInstallationId(function(id) {
        // update the view to show that we have the install ID
        console.log('Retrieved install id: ' + id);               

      }, function(e) {
        console.log('Failure to retrieve install id.');
      });

  }, function(e) {
      console.log('Failed trying to subscribe to SampleChannel.');
  });

}, function(e) {
    console.log('Failure to initialize Parse.');
});
raju
  • 4,788
  • 15
  • 64
  • 119

2 Answers2

2

you need to register a callback

https://github.com/aaronksaunders/dcww/blob/master/www/js/parseService.js#L60

registerCallback: function (_pushCallback) {
    var deferred = $q.defer();
    $window.parsePlugin.registerCallback('onNotification', function () {

        $window.onNotification = function (pnObj) {

            _pushCallback && _pushCallback(pnObj);

            alert('We received this push notification: ' + JSON.stringify(pnObj));
            if (pnObj.receivedInForeground === false) {
                // TODO: route the user to the uri in pnObj
            }
        };
        deferred.resolve(true);

    }, function (error) {
        deferred.reject(error);
    });
    return deferred.promise;

}

see the complete example here : https://github.com/aaronksaunders/dcww

Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80
0

use custom receiver as here

and then use flag for your context.startActivity(intent) as here

also you can ask for intent.getAction() to know which intent filter launch your receiver

Community
  • 1
  • 1
itzhar
  • 12,743
  • 6
  • 56
  • 63