@dlhuffmanjr wrote:
I recently upgraded my Push service to use ionic-cloud. Before using this I had been doing the following to setup the requisite handlers in the init method of the $ionicPush service:
$ionicPush.init({ "onNotification": function (notification) { var payload = notification.payload; console.log("onNotification payload", payload); return true; }, "onRegister": function (data) { console.log("onRegister, token", data.token); $ionicPush.saveToken(data.token); } }); $ionicPush.register();
Now I have decoupled it as follows which works nicely except I have not been able to find the right way to insert the handler for when the user clicks the notification:
$ionicPush.register().then(
function (t) {
console.log("register, t", t);
$ionicPush.saveToken(t).then(
function (t) {
console.log('Token saved:', t.token);
}
)
},
function (error) {
console.error("register", error);
});In short, I am looking to handle the onNotification handler in the new logic.
I tried (per the docs):
$scope.$on('cloud:push:notification', function (event, data) {
console.debug("data", data);
});AND
$ionicEventEmitter.on('push:notification', function(notification) {
console.debug("notification", notification);
return true;
});which lead to dead ends.
Anyone able to assist?
Thanks!
Posts: 1
Participants: 1