我在GCM: Getting Started的帮助下准备了一份GCM申请。工作正常。我在Emulator中收到消息。我已在设备中安装了我的应用程序。当我从服务器Emulator发送消息时,仅收到消息,但设备未收到消息。我认为在某些地方做了一些错误,请指导我。

最佳答案

你在GCM注册了设备吗?
要获取注册ID,必须执行以下代码:
在oncreate()方法中,添加以下代码:

GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
  GCMRegistrar.register(this, SENDER_ID);
} else {
  Log.v(TAG, "Already registered");
}

在这里您将得到regid,您必须将其发送到服务器,以便服务器可以向具有上述regid的设备发送推送通知。
有关更多帮助,请参阅here

关于android - 模拟器仅收到GCM消息?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11627428/

10-11 22:29
查看更多