收到GCM推不WLClient ::连接() [英] receive GCM push without WLClient::connect()

查看:201
本文介绍了收到GCM推不WLClient ::连接()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们能 WLPush ::订阅()没有 WLClient ::连接()

背景结果
我工作在Android原生应用程序的 - 使用IBM工作灯框架(离线版本应用程序可在没有互联网的情况下工作),和我实现推送通知。据我了解,我们需要 WLPush ::订阅()为了得到通知。但是,我们不能直接调用订阅()方法,它必须是在回调 OnReadyToSubscribeListener 。一旦连接建立的侦听器将被调用。

Background
I'm working on an Android native application (offline version - App can work in case of no Internet) using the IBM Worklight framework, and I am implementing push notification. As I understand, we need WLPush::subscribe() in order to get the notification. But we cannot directly invoke the subscribe() method, it has to be in the Callback OnReadyToSubscribeListener. The listener will be invoked once connection is established.

所面临的问题是:


  1. 的应用程序被注册到GCM

  2. 该应用程序已终止

  3. 系统推送通知被设备接收,我已经看到了该通知。

但我不能让 WLEventSourceListener 引用...因为我需要连接订阅!这没有任何意义,我 - 因为我们已经在客户端控制台(DDMS)所示的通知

But I couldn't get the WLEventSourceListenerinvoked... because I need to connect before subscribe! This doesn't make any sense for me - because we have already have the notification shown in client console(DDMS).

我知道,我大概可以:


  • 覆盖 GCMIntentService

  • 强制 WLClient ::连接()来触发的 TIMING

  • Override GCMIntentService
  • Force WLClient::connect() to trigger the TIMING

有人能提供一个更好的解决方案?

Can someone offer a better solution?

更新于10月31日

我使用的是WL Android原生推示例项目,发现它是不可能得到回调WLEventSourceListener调用时没有连接。

I am using the "WL Android native push" sample project and found that it is impossible to get the callback WLEventSourceListener invoked without connect.

重现步骤:


  1. 启动样本客户

  2. 单击连接连接到服务器

  3. 连接成功返回,点击订阅订阅

  4. 在Eclipse IDE中,右键单击推适配器推送到客户端

  5. 在客户端,它接收推送消息(在DDMS控制台日志所示),并调用 WLEventSourceListener

  6. 杀死在App

  7. 重新发送推

  8. Push信息显示在DDMS控制台日志,并在通知栏通知。

  9. 单击该通知时,应用程序启动。

  10. WLEventSourceListener 当再次点击连接按钮进行调用。

  1. Launch the sample client
  2. Click the "connect" to connect to server
  3. Connection returns successfully, click "subscribe" to subscribe
  4. In Eclipse IDE, right click the push adapter to send a push to client
  5. At client side, it receives the push message(shown on DDMS console log) and WLEventSourceListener is invoked.
  6. Kill the App
  7. Resend the push
  8. Push message is shown in the DDMS console log, and a notification in the notification bar.
  9. App is launched when the notification is clicked.
  10. The WLEventSourceListener get invoked when connect button is clicked again.

下面是个问题。在第9步,推消息到达客户端,但在第10步,连接必须调用获得 WLEventSourceListener 进行调用。有没有办法让没有连接的信息?

Here is the question. In step 9, the push message reaches the client, but in step 10, connect must be invoked to get WLEventSourceListener invoked. Is there a way to get the message without connect?

推荐答案

为了认购推送通知,应用程序需要连接到服务器工作灯。因此,虽然应用程序也可以离线工作,它需要至少一次,是在线,并办理认购过程,因为它连接到工作灯服务器。

In order to subscribe for push notifications, the application is required to connect to the Worklight Server. So while the application can also work offline, it will need to, at least once, be "online" and go through the subscription process as it connects to the Worklight Server.

的工作灯服务器分派通知,然后经过谷歌的GCM服务,最终将其发送到已注册装置。

The Worklight Server dispatches the notifications, which then go through Google's GCM service, which eventually sends it to the registered device.

然后,它是监听器的宗旨,以收到的通知传递给应用程序,打开它,让应用程序逻辑来处理(显示)它。

Then, it is the listener's purpose to pass the received notification to the application, open it and let the app logic to handle (display) it.

事件源通知的绑定到用户 - 这是怎么了IBM提供的示例应用程序中实现 - 这意味着,只有当用户登录后,已发送到该通知用户将被显示。测井中通常需要验证用户,这是对工作灯服务器上完成, ,这意味着需要连接

Event source notifications are bound to a user - this is how the sample application provided by IBM is implemented - This means that only once the user has logged-in, the notification that was sent to that user will be displayed. Logging-in typically requires authenticating the user, which is done against the Worklight Server, which means a connection is required.

例如,让我们说,用户使用相同的设备。用户#1接收到通知,但用户#2当前正在使用该设备。如果用户#2将打开瓦特/鉴权,用户#2将收到实际上为用户#1发送通知的应用程序。

For example, let us say that 2 users use the same device. User #1 received a notification, but user #2 is currently using the device. If user #2 will open the app w/out authentication, user #2 will receive the notification that was in fact sent for user #1.

这带来了以下几个问题:

This brings up the following questions:


  1. 什么是您的应用程序的情况?

  2. 是你的情况需要身份验证?

如果验证的不需要的,那么你需要看的广播的或的标签的通知类型。这些通知类型将允许回调被调用的无需连接要求

If authentication is not required, then you need to look at the broadcast or tag notification types. These notification types will allow for the callback to be invoked without the connection requirement .

注:上面的通知类型,你必须至少工作灯6.2使用结果。
你可以阅读更多有关这些,在这里:<一href=\"http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/admin/c_push_notification.html\" rel=\"nofollow\">http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/admin/c_push_notification.html

Note: for the above notification types, you must use at minimum Worklight 6.2.
You can read more about these, here: http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/admin/c_push_notification.html

这篇关于收到GCM推不WLClient ::连接()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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