Send Message Using GCM [closed]

梦想与她 提交于 2019-12-25 18:46:02

问题


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


回答1:


You don't need a server.

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

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",
  },
}

Receive: using Google's GCM system to receive via intents as described here: http://developer.android.com/google/gcm/client.html




回答2:


I want to know whether it is possible for sending a message from one android mobile to another using GCM ?

Yes , it is possible.

Can android mobile act as server to post message via GCM?

No , You will need to use 3rd party server to communicate between two mobile phones.

Full information is available here.



来源:https://stackoverflow.com/questions/20901597/send-message-using-gcm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!