@MeetingHand wrote:
THE SITUATION:
I am using Ionic Push notifications in my app.
Everything is working fine.
When the user send a message, the notification will be fired through a cURL request, and it will arrive only if the receiver has the app off or in background.
I have just a problem handling the onClick callback.
Following the documentation I have put the callback function in the onNotification parameter.
"onNotification": This function will be called when your device receives a notification, and provided with the notification object received.
What I need to do, when the user click on the notification, is to redirect him to a certain page.
It is working.
The problem is that when the user is inside the app, it will be automatically redirected to that page everytime he will receive a message. When the notification is fired by not actually received because the app is in foreground
And in this the onNotification will be called anyway...
THE CODE:
.run(function($ionicPlatform, $rootScope, $location, $state) { $ionicPlatform.ready(function() { var push = new Ionic.Push({ "debug": true, "onNotification": function(notification) { if ( $state.current.name != 'app.attendee-chat' ) { $rootScope.get_my_account_data(); $location.path('app/attendee_list'); } }, "onRegister": function(data) { console.log(data.token); }, });
THE QUESTION:
How can I manage to setup a callback function that will be called ONLY when the user actually click on the notification, and not when he is inside the app?
I have to do some tricks inside the onNotification or there is a possibility to setup a onClick callback?
Thank you!
Posts: 1
Participants: 1