【发布时间】:2014-12-27 16:05:08
【问题描述】:
// 这不是重复的。这是this question 和其他同一主题的后续问题
我正在使用 Angular 和 Coffeescript 开发一个 PhoneGap 应用程序,我希望它在单击不同的移动通知(GCM 和 APN)时打开不同的视图。
我关注了这个explanation 和这个question。我在消息中发送所需视图的名称,并在 notificationHandler 中提取视图的名称,然后切换到它。
但是,似乎在单击通知时,首先加载应用程序,然后才加载通知处理程序 - 因此应用程序首先在默认视图上打开,然后才更改为所需的视图。我该如何解决?
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)
【问题讨论】:
标签: android angularjs cordova coffeescript