如何判断应用程序是通过点击推送消息通知开始 [英] How to tell app was started by tapping push message notification

查看:720
本文介绍了如何判断应用程序是通过点击推送消息通知开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有接收从服务器推送通知的工作灯的应用。的通知,意味着有来自其他用户的当前用户新邮件。用户将通过访问应用程序内的信息页面,然后继续到一个特定的会话页面阅读。

I have a Worklight app that receives push notifications from the server. A notification means there are new messages for the current user from other users. A user would read them by visiting a messages page within the app and then proceeding to a particular conversation page.

我想在用户的意图之间的code分化。该应用程序将:

I would like to differentiate in the code between user intentions. The app would:


  1. 如果用户启动应用程序,通常(而不是通过点击一个新的通知),present与普通应用程序主屏幕的用户。

  2. 如果用户启动/通过点击通知,present与信息页面的用户恢复应用程序。

  3. 如果收到,而应用程序是在前台,只有(不管是哪个页面被激活)更新屏幕上的信息数量。

现在的问题是:是否有上述条件区分了可靠的手段。

The question is: is there a reliable means to differentiate between the above conditions?

在另一个线程,我看到了一个建议,要记住简历事件的时间戳和onReadyToSubscribe事件,我们假定我们都睡着了/不活跃,如果通知到达例如只是在这之后第二个。这将使箱2和3之间区分。

In another thread, I saw a suggestion to remember the timestamp of a resume event and an onReadyToSubscribe event and assume we were asleep/inactive if notification arrives e.g. just a second after this. This would enable me to differentiate between 2 and 3.

然而,1不被此覆盖。即如果有新的消息,但用户正常启动的应用程序,该应用程序将有知道这没有办法,并会认为它是由攻通知启动。通过这种方式,用户打算看到应用程序的主屏幕,但我们他转移到信息页面。

However, 1 is not covered by this. I.e. if there have been new messages, but the user started the app normally, the app would have no means of knowing this and would think it was started by tapping a notification. This way, the user intended to see app home screen, but we transfer him to the messages page.

有没有解决这个可靠的方式为iOS和Android?

Is there a reliable way around this for both iOS and Android?

工作灯vesion 6.2.0.00-20140922-2259。

Worklight vesion 6.2.0.00-20140922-2259.

推荐答案

在一个纯粹的原生应用程序,你可以知道,其中从用户打开应用程序,这意味着它是否是通过点击收到的通知或通过轻按应用程序图标。

In a pure Native application, you can know "where from the user opened the app", meaning whether it was by tapping on a received notification or by tapping the application icon.

在基于工作灯,混合应用程序, ,如果只使用的JavaScript API ,这是不可行的,因为所有的路径到达同一目的地也就是 pushNotificationReceived 功能。因此,无论您点击一个通知或应用图标或所带来的应用前景,上述功能将被调用。

In a Worklight-based Hybrid application, and if using only the JavaScript API, this is not feasible because all paths arrive to the same destination which is the pushNotificationReceived function. So whether you tapped a notification or the app icon or brought the app to the foreground, the aforementioned function will be invoked.

结果
该解决方案可能是立足于以下知识中心文档主题的实现:<一href=\"http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/devref/c_push_notifications_hybrid.html\"相对=nofollow>使用本机和JavaScript API的推在同一个应用。

这样的话,使用本地code和JS code的组合,您可以处理,其中收到通知的情况下,但用户决定挖掘的应用程序图标,而不是通知。

This way, using a combination of native code and JS code, you could handle the scenario where a notification was received but the user decided to tap the application icon rather than the notification.

这是终端到终端的例子将有所参与实施,但如果你按照文档主题中的code的例子,你应该得到有...

An end-to-end example would to somewhat involved to implement, but if you'll follow the code examples in the documentation topic, you should get there...

这篇关于如何判断应用程序是通过点击推送消息通知开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆