I am using the following plugin for push notification.
I just need to redirect to certain page in ionic when user click on push notification.
I am using the following plugin for push notification.
I just need to redirect to certain page in ionic when user click on push notification.
+1 I am also trying to do this.
When registering pushPlugin you can pass config object, within this object you can add a property for your notification callback i.e. "ecb" : "angular.element(document.querySelector('[ng-app]')).injector().get('PushNotificationService').notify"
Then you can write your notify method like so:
@notify = (notification)->
console.log "notification"
androidPushService.handleNotification(notification) if ionic.Platform.platform() is 'android'
iOSPushService.handleNotification(notification) if ionic.Platform.platform() is 'ios'
And finally
# Android
@handleNotification = (notify)->
switch notify.event
when 'registered'
if notify.regid.length > 0
console.log('REGISTERED with GCM Server -> REGID:' + notify.regid)
tokenDetails =
platform : "android"
token : notify.regid
$rootScope.$broadcast('receivedPushNotToken', tokenDetails)
when 'message'
# Display $ionicPopup here and react to button press
when 'error'
console.log('ERROR -> MSG:' + notify.msg + '')
else
console.log('EVENT -> Unknown, an event was received and we do not know what it is')
im using ionic push with payload , see the example
Anyone managed to do this well in Ionic 2? I struggle with getting to know if the app was open from notification or not.
EDIT: here is an issue https://github.com/phonegap/phonegap-plugin-push/issues/501
This can be tested easily by checking notification.additionalData.coldstart == false
then app is in forground. Otherwise it is in background and opened because of notification click.