黑莓手机 - 接收内部应用推送消息 [英] BlackBerry - Receive Push Message inside App

查看:300
本文介绍了黑莓手机 - 接收内部应用推送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功开发出了黑莓应用程序的注册了 BlackBerry推送消息服务并接收推送消息。在推送消息收到一个弹出消息。我处理在后端显示在在应用程序中此消息聊天屏幕我创建。当发送到设备的推送消息是存储在数据库中,以及。该应用程序有一个计时器运行查询数据库的任何新的消息,并显示在应用程序内。然而,这种方法不是那么有效,因为我的目标是一旦它被作为一个推送消息发送显示该消息。我的问题如下:

I have successfully developed a BlackBerry App that registers for BlackBerry Push Messaging Service and receives push message. The Push Message is received as a pop-up message. I am handling at the back end to show this message inside the App in a Chat Screen that I have created. The push message when sent to the device is stored in a database as well. The App has a timer running that queries the database for any new message and displays it inside the app. However this approach is not so efficient as I aim to display the message as soon as it is sent as a push message. My questions are as follow:


  1. 当应用程序被关闭,服务器发送一个推送消息,将这个消息传递?

  2. 当收到一个推送消息,你怎么强行启动的应用程序?

  3. 是否有任何特定的API或可用于检测方法收到推送消息时?

  4. 我能够收到消息时改变应用程序的图标。不过,我想这是作为推送消息尽快更改是收到弹出。所以,我怎么可以检测当推送消息收到以外运行的后台计时器?

  1. When the App is closed and the server sends a push message, will this message be delivered?
  2. When a push message is received, how do you force-start an app?
  3. Is there any particular API or method available to detect when a push message is received?
  4. I am able to change the App icon when a message is received. However, I want this to change as soon as the push message is received as the pop-up. So how can I detect when the push message is received other than running a background timer?

请指导。

推荐答案

我同意轮询新的消息的数据库不是一个好的解决方案。

I would agree that polling a database for new messages is not a good solution.

我会做的就是<一个href=\"http://docs.blackberry.com/en/developers/deliverables/34499/Detect_a_UiAction_entry_point_1461108_11.jsp\"相对=nofollow>实现两个的切入点的在您的应用程序:

What I would do is to implement two entry points in your app:

1),后台进程,它扩展了黑莓应用类。这就是非图形,并侦听推送通知。

1) A background process, that extends the BlackBerry Application class. This is non-graphical, and will listen for push notifications.

2)一个正常的UI,我想你指的是为应用程序。这将延长的UIApplication 类。

2) A normal UI, which I think you're referring to as "the App". This will extend the UiApplication class.

当您的背景进程收到推送通知,你可以再选择打开的UIApplication 让你的用户能够处理新的聊天消息。

When your background process receives push notifications, you can then choose to open up the UiApplication so your user can handle the new chat message.

要回答你的问题:


  1. 是的,推送通知将被接收,因为后台进程始终运行(你应该确保检查自动运行在启动箱中的BlackBerry_App_Descriptor.xml文件中,为后台入口点)。 详见这里

  1. Yes, the push notification will be received, because the background process is always running (you should make sure to check the Autorun at Startup box in the BlackBerry_App_Descriptor.xml file, for the background entry point). See more here.

后台进程可以把UI应用程序与此code 前景

The background process can bring the UI application to the foreground with this code.

有多种方法来接收推送通知...见下面的链接。这听起来像你已经有这个实施。我觉得关键,不过,是你把你推处理code在背景 应用。然后,你的UI应用程序不需要任何特殊的API。您的后台应用程序只需打开UI时,它的时间。它可以选择将数据传递给使用这种技术中的UI应用程序

There's multiple ways to receive push notifications ... see links below. It sounds like you already have this implemented. I think the key, though, is that you put your push handling code in the background Application. Then, your UI application doesn't need any special APIs. Your background application simply opens the UI when it's time. It can choose to pass data to the UI application with this technique.

再次你要设置两个入口点:一个背景应用,和一个正常的的UIApplication 。背景应用程序在启动时运行,注册推送通知,并接收推送通知,因为他们进来(无轮询)。然后,您可以决定做什么,包括开放你的UI(的UIApplication )。

Again, you'll want to setup two entry points: one background Application, and one normal UiApplication. The background application will run on startup, register for push notifications, and receive push notifications as they come in (without polling). You can then decide what to do, including opening up your UI (UiApplication).

下载SDK推,你'终有一天会发现样本code在那里。

When you download the Push SDK, you'll find sample code in there.

在黑莓的Eclipse插件,您可以导入... - > 导入黑莓样品 - > HTTPPushDemo 更多演示源。

Within the BlackBerry Eclipse Plugin, you can Import... -> Import BlackBerry Samples -> HTTPPushDemo for more demo source.

教程:制作一个应用程序启用推( OS 6.0 +)

Tutorial: Making an app push-enabled (OS 6.0+)

这篇关于黑莓手机 - 接收内部应用推送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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