drqyxkzbs21968684 2014-03-31 21:13
浏览 38

无法使用GCM建立设备到设备的消息传递

I am trying to establish device to device messaging using Google Cloud Messaging. I tried using socket programmng, but the connection used to get lost everytime I moved to the next page. Thus I am using GCM. The plan is to send a message from client's phone and it should be displayed on server's phone, using 3g/wifi and not bluetooth.

I am referring the following link for the same:

http://androidexample.com/Device_To_Device_Messaging_Using_Google_Cloud_Messaging_GCM_-_Android_Example/index.php?view=article_discription&aid=122&aaid=142

It has no errors and is running, but nothing is displaying on the screen. Also a few doubts:

  1. In the code in CommonUtilities.java what should be the Server_Url? I am using XAMPP, so should it be XAMPP's URL?
  2. Also, what should be the Sender_ID?
  3. Also in MainActivity.java, what should be the device IMEI? Do we have to enter that manually, or will the device fetch on ots own.
  4. Also in the php files, its written enter "GCM Registeration ID got from device".Is it client's ID? I am running using Google API and registering my ID in the settings of the emulator before proceeding further.

Can anyone please tell me where am I going wrong? Or even if you have a better idea, please do share here. I am looking for mobile to mobile communication only, not using push notifications.

  • 写回答

1条回答 默认 最新

  • duancuan7057 2014-03-31 21:55
    关注
    GCM is working as follow:
    

    1/First of all you have to register your application in google and get your Sender_ID

    2/the client connect to GCM cloud in order to register it self (using the SENDR_ID)

    3/GCM cloud send a registrationID to the client

    4/You should make a server so that you save the registrationID of any device that runs your apps

    If you want to send a GCM notification from one client to server
    

    1/the client should connect to your server

    2/tell the server to make a demande to the GCM cloud containing the registrationID of the server so that the GCM send the notification to the server

    you will find a detailed explanation here

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看