发送短消息使用GCM [英] Send Message Using GCM

查看:192
本文介绍了发送短消息使用GCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能通过本地服务器发送从一个Android手机到Android手机的通知?

I want to know whether it is possible for sending a notification from one android mobile to android mobile via a local server?

推荐答案

您不需要服务器。

发送:您的手机可以(连同消息),然后将消息传递到目标设备(S)执行HTTP POST一些JSON描述发件人/注册ID的谷歌的服务器上。细节在这里: http://developer.android.com/google/gcm/c2dm.html

Send: Your phone can perform a HTTP POST to Google's servers of some JSON describing the sender/registration ids (along with the message), which then passes the message to the target device(s). Details here: http://developer.android.com/google/gcm/c2dm.html

请注意,该页面描述了从C2DM移植到GCM。什么我建议这里是新GCM方法。基地在该网页上您的最后一个例子JSON:

Note that that page describes migration from C2DM to GCM. What i'm suggesting here is the new GCM method. Base your JSON on the last example on that page:

Content-Type:application/json
Authorization:key=AIzaSyB-1uEai2WiUapxCs2Q0GZYzPu7Udno5aA

    {
  "registration_id" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
  "data" : {
    "Team" : "Portugal",
    "Score" : "3",
    "Player" : "Varela",
  },
}

接收:使用谷歌的GCM系统通过意图接收如下所述:的http:// developer.android.com/google/gcm/client.html

这篇关于发送短消息使用GCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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