【发布时间】:2016-06-08 04:33:40
【问题描述】:
我在Android上关注Google Cloud Messaging (GCM) with local device groups on Android gives HTTP Error code 401管理本地设备组并成功获得了通知密钥,但是当我向通知密钥发送消息时,我再也没有收到消息。 有人做过这个工作吗?
我的发送代码是这样的:
public void sendMessage(View view) {
AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
try {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
String to = notificationKey; // the notification key
AtomicInteger msgId = new AtomicInteger();
String id = Integer.toString(msgId.incrementAndGet());
Bundle data = new Bundle();
data.putString("hello", "world");
gcm.send(to, id, data);
Log.e(TAG, "sendMessage done.");
} catch (Exception ex) {
Log.e(TAG, ex.toString());
}
return null;
}
};
task.execute();
}
【问题讨论】:
-
@greywolf82,你成功发送消息到本地设备组了吗?
标签: android google-cloud-messaging