搭建Android MQTT推送平台
2013-08-01 11:31
597 查看
最近研究了一下Android推送,在网上搜到了很多种方式,觉得IBM的MQTT协议这种方式还是挺不错的。
下面介绍一下搭建过程:
需要准备的工具如下:
[b](1)、下载Mosquitto(MQTT的代理,也可以用IBM的ISMB)[/b]
http://mosquitto.org/download/
我下载的是mosquitto-1.1.2-install-win32.exe,根据自己的需要下载,不安装这个推送不了消息。
(2)、下载AndroidPushNotificationsDemo
https://github.com/tokudu/Androi ... /archive/master.zip
(3)、下载PhpMQTTClient
https://github.com/tokudu/PhpMQTTClient/archive/master.zip
将PHPMQTTClient部署到PHP服务器上,运行,打开mosquitto安装目录的mosquitto.exe
将以下AndroidPushNotificationsDemo的代码根据自己的情况修改。
输入Device target ID ,内容,点击按钮,OK!
PS:
原来其实是不需要那个PHP的,直接用mosquitto_pub.exe就可以测试了,运行客户端程序,在命令窗口中使用Mosquitto_pub.exe -q [Qos级别] -t [主题] -m [发布的内容] 进行测试。这个android客户端例子中订阅的topic是“tokudu/你的deviceID”。
一些别的资料:
http://www.cnblogs.com/yjl49/archive/2012/05/17/2506819.html
下面介绍一下搭建过程:
需要准备的工具如下:
[b](1)、下载Mosquitto(MQTT的代理,也可以用IBM的ISMB)[/b]
http://mosquitto.org/download/
我下载的是mosquitto-1.1.2-install-win32.exe,根据自己的需要下载,不安装这个推送不了消息。
(2)、下载AndroidPushNotificationsDemo
https://github.com/tokudu/Androi ... /archive/master.zip
(3)、下载PhpMQTTClient
https://github.com/tokudu/PhpMQTTClient/archive/master.zip
将PHPMQTTClient部署到PHP服务器上,运行,打开mosquitto安装目录的mosquitto.exe
将以下AndroidPushNotificationsDemo的代码根据自己的情况修改。
public class PushService extends Service { // this is the log tag public static final String TAG = "DemoPushService"; // the IP address, where your MQTT broker is running. //修改成自己的服务器地址
private static final String MQTT_HOST = // "209.124.50.174" // "192.168.12.19" "10.0.2.2" ; // the port at which the broker is running. private static int MQTT_BROKER_PORT_NUM = 1883; // Let's not use the MQTT persistence. private static MqttPersistence MQTT_PERSISTENCE = null;
输入Device target ID ,内容,点击按钮,OK!
PS:
原来其实是不需要那个PHP的,直接用mosquitto_pub.exe就可以测试了,运行客户端程序,在命令窗口中使用Mosquitto_pub.exe -q [Qos级别] -t [主题] -m [发布的内容] 进行测试。这个android客户端例子中订阅的topic是“tokudu/你的deviceID”。
一些别的资料:
http://www.cnblogs.com/yjl49/archive/2012/05/17/2506819.html
相关文章推荐
- 搭建Android MQTT推送平台
- 基于AndroidPN搭建Android的推送平台 - 离线消息的推送
- 基于Apollo代理服务器的MQTT推送平台搭建
- [移动] Android推送方案分析(MQTT/XMPP/GCM) 服务器的搭建
- 利用AndroidPN,搭建自己的Android推送平台
- 基于AndroidPN搭建Android的推送平台
- Mosquitto搭建Android推送服务(一)MQTT简介
- 学习Android推送功能笔记(9)---搭建推送平台
- Ogrekit源码Windows平台编译_Android环境搭建
- Android推送方案分析(MQTT/XMPP/GCM)
- 使用Jenkins搭建iOS/Android持续集成打包平台
- 基于windows平台的Android原生(Native)C开发环境搭建
- Android平台IDA so调试环境搭建
- Android推送方案分析(MQTT/XMPP/GCM)
- Android平台cocos2d-x学习之——平台搭建
- Android 平台搭建.
- Android消息推送(二)--基于MQTT协议实现的推送功能
- 服务器主动向android手机端推送消息---------Linux下Androidpn环境搭建
- Android消息推送(二)--基于MQTT协议实现的推送功能
- android 平台搭建