我正在创建一个 android 应用程序,我需要在其中发送 gcm 消息。
到目前为止我设法得到设备ID并将其发送到我的服务器。
现在,当我尝试将消息从服务器推送到我的应用程序时,我收到以下消息:{"multicast_id":4987023356709284342,"成功":1,"失败":0,"canonical_ids":0,"结果":[{"message_id":"0:1430085972465424%73c650e3f9fd7ecd"}]},但设备上没有任何反应(应用程序是否运行并不重要)。
这是我的相关代码:
Manifest.xml----------------- AndroidManifest.xml http://tziuka.com/code/taxi/AndroidManifest.html
BroadcastReceiver-------- GcmBroadcastReceiver http://tziuka.com/code/taxi/GcmBroadcastReceiver.html
IntentService---------------- GcmIntentService http://tziuka.com/code/taxi/GcmIntentService.html
Register---------------------- GcmRegister http://tziuka.com/code/taxi/GcmRegister.html
here I am using the register class (look for 'GCM HERE' tag)
LoginActivity---------------- LoginActivity http://tziuka.com/code/taxi/LoginActivity.html
here is my android project structure
Structure--------------------- structure http://tziuka.com/code/taxi/structure.jpg
Server side [PHP]
GcmPush ------------------- GcmPush.php http://tziuka.com/code/taxi/GcmPush.html
and this is how I'm using GcmPush.php
SendMessage-------------- send function http://tziuka.com/code/taxi/send.html
希望可以有人帮帮我。
指出我做错了什么......
谢谢你!
最后我发现...
我把日志放进去Gcm接收,并打印日志:),然后我去了意向服务,在那里我发现消息已经到达但通知实际上并没有通知该消息。
到目前为止,我还没有发现我的通知有什么问题,但是我认为这一行有问题:
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
我很高兴最大的问题得到了解决。现在我正在寻找我在通知方面做错了什么。
非常感谢所有试图提供帮助的人...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)