我是andriod的新手,现在正在使用pubnub在聊天应用中工作。它需要的推送格式为pn_gcm.data。我正在发送该地图<>数据到punub服务器。我正在测试gcm接收器http://apns-gcm.bryantan.info/它的工作正常我从这个Web应用服务器获取通知。但是什么时候用pn_gcm发布消息给punbub我没有收到来自gcm的通知。有什么不对劲请帮助我 我的订阅通知:
//CallBackMethod {
final TaskCompletionSource<Boolean> task = new TaskCompletionSource<>();
this.vinepub.pubnub.addPushNotificationsOnChannels()
.channels(channels)
.deviceId(gcmRegID)
.async(new PNCallback<PNPushAddChannelResult>() {
@Override
public void onResponse(PNPushAddChannelResult result, PNStatus status) {
// handle response
if (!status.isError()) {
Logger.info("Channels registered for push notifications" + channels);
taks.setResult(Boolean.TRUE);
}
else {
Logger.info("Failed to registered the channels for push notifications" + channels);
taks.setResult(Boolean.FALSE);
}
}
});
}
return task.getTask();
}
------------------------------------------------------------------------
//发布方法
Logger.info("Sending message to the channel" + channel);
// Publish the message and pushNotification to channel
Map<String, Object> messagepayload = new HashMap<>();
messagepayload.put("message", messageEnvelope.getMessageEnvelopeString());
Map<String, Object> datapayload = new HashMap<>();
datapayload.put("data", messagepayload);
Map<String, Object> mobilePayload = new HashMap<>();
mobilePayload.put("pn_gcm", datapayload);
mobilePayload.put("messages", message);
mobilePayload.put("pn_debug", true);
if (this.pubnub != null) {
this.pubnub.publish()
.message(mobilePayload)
.channel(channel)
.shouldStore(true)
.usePOST(true)
.async(new PNCallback<PNPublishResult>() {
@Override
public void onResponse(PNPublishResult result, PNStatus status) {
if (status.getStatusCode() == 200) {
callback.onSuccess(true);
}
else {
PNErrorData pnErrorData = status.getErrorData();
callback.onFailure(pnErrorData.getThrowable());
}
}
});
}