// This is not a duplicate. It's a follow-up question on this question and others on the same topic
I'm developing a PhoneGap app using Angular and Coffeescript, and I want it to open different views when different mobile notification are clicked (GCM and APN).
I've followed this explanation, and this question. I'm sending the name of the required view inside the message, and in the notificationHandler I'm extracting the name of the view and then switch to it.
However, it seems that when the notification is clicked, first the app is loaded, and only then does the notification handler is loaded - so the app is first opened on the default view, and only then changes to the required view. How do I fix it?
gcmNotificationsHandler.coffee:
switch e.event
when "registered"
...
when "message"
console.log("DEBUG: mobile notification: Foreground? [#{e.foreground}] Coldstart? [#{e.coldstart}] Background? [#{not(e.foreground or e.coldstart)}]")
notificationAction = parseNotificationParams(e.payload)
if notificationAction.actionRequired
if e.foreground
console.log("DEBUG: Recieved message on foreground, moving to #{JSON.stringify(notificationAction)}")
$state.go notificationAction.toState, notificationAction.stateParams
else # otherwise we were launched because the user touched a notification in the notification tray.
console.log("DEBUG: Recieved message on background, saving next state as: #{JSON.stringify(notificationAction)}")
LocalStorage.setObject('STATE.new_notification', notificationAction)