推通知让设备位置 [英] push notification to get device location

查看:130
本文介绍了推通知让设备位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想使用Android设备上的推送通知和详细信息,结果获得设备位置
我想写的应用程序为Android,当服务器希望得到Android设备的位置及时推送通知到设备,及时对设备发送设备位置服务器的应用程序。结果
因为这种服务需要我不能使用云到设备通讯服务,用户第一次上网后用户与服务C2DM发送在线服务器通知!。但我想通知发送到设备,并得到任何时候服务器需要设备的位置。


解决方案

  1. 为了取得可能的任何形式的推送通知,您的客户将需要在线。离线客户端不能接受推送通知,直到它的在线。


  2. 一个C2DM推送可以通过服务器启动。无需客户端来启动它。服务器只需要发送一个消息到C2DM服务器和通知将被发送


  3. 什么你基本上需要做的是,在收到来自C2DM服务器的通知,让你的C2DM基站接收机调用一个函数,使用它检索客户端的位置数据的LocationManager 并将其发送给服务器。


编辑MQTT:

我还没有做过这么多的自己,但它可以用于推送服务

您需要:

它运行在服务器端,像mosquitto经纪人这是开源的。一个MQTT经纪人

您在您的Andr​​oid应用程序,让您的应用程序连接,订阅和发布消息的MQTT客户机库。请参阅本 http://mqtt.org/software

要拿出的唯一标识用户或设备的方式,然后使用它作为一个话题,这样就可以单独发布一条消息到一个设备。

Hi i want to use push notification on android device and get device location for more information
I want to write application for android that when server want to get android device location push a notification timely to the device and the application on the device send device location to server timely.
I can't use Cloud to device messaging service because this service need that user first online and after user is online send server notification with C2DM service!.But i want to send notification to device and get device location any time server wants.

解决方案

  1. For any sort of push notification to be made possible, your client will need to be online. An offline client cant accept push notifications until it is online.

  2. A C2DM push can be initiated by the server. No need for client to start it. The server just needs to send a message to the C2DM server and notification will be sent.

  3. What you basically need to do is, on receiving the notification from C2DM server, make your C2DM base receiver call a function, which retrieves the clients location data using LocationManager and send it to the server.

EDIT for MQTT:

i havent done this much myself but it can be used for push service

You need:

an MQTT broker which runs on the server side, like the mosquitto broker which is Open Source.

an MQTT client library which you include in your Android app, enabling your app to connect, subscribe, and publish messages. refer this http://mqtt.org/software

to come up with a way of uniquely identifying users or devices, and then use that as a topic so that you can individually publish a message to one device.

这篇关于推通知让设备位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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