gpt4 book ai didi

android - PhoneGap 根据通知内容打开页面

转载 作者:行者123 更新时间:2023-11-30 02:28:05 26 4
gpt4 key购买 nike

//这不是重复的。这是关于 this question 的后续问题和其他人在同一主题上

我正在使用 Angular 和 Coffeescript 开发一个 PhoneGap 应用程序,我希望它在点击不同的移动通知(GCM 和 APN)时打开不同的 View 。

我关注了这个 explanation ,还有这个 question .我在消息中发送所需 View 的名称,在 notificationHandler 中我提取 View 的名称,然后切换到它。

但是,似乎在单击通知时,首先加载应用程序,然后才加载通知处理程序 - 因此首先在默认 View 上打开应用程序,然后才更改为所需 View 。我该如何解决?

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)

最佳答案

if (e.foreground)
{
// ECB message event come here when your app is in foreground(not in background)
}
else
{
if (e.coldstart)
{
// ECB message event come here when you touch notification from notification tray
}
else
{
// ECB message event here when your app is in background
}
}

因此,使用 e.coldstart 并使用 $location angular js 指令(或任何其他不使用 angular js 的指令)重定向到页面。

请引用以下链接:

关于android - PhoneGap 根据通知内容打开页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27647207/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com