如何从接收端GCM得到MESSAGEID [英] How to get messageId from gcm on receiver side

查看:162
本文介绍了如何从接收端GCM得到MESSAGEID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能成功运行的客户端和GCM的服务器。但是,当我从服务器端发送消息时,我可以从一个GCM邮件ID,它是这样的:
  0:1408673696996426%921c249a002efde3

I can successfully run the client and server of gcm. But when I send message from server side, I can get a messageId from gcm, which is something like this: 0:1408673696996426%921c249a002efde3

不过,我无法从客户端(android的侧)MESSAGEID。通过聆听的onMessage事件,我可以从意向获取信息数据和我的onMessage code是这样的:

However, I can not get this messageId from client side(android side). By listening to onMessage event, I can retrieve message data from intent and my onMessage code is like this:

protected void onMessage(Context context, Intent intent) {
    Log.i(TAG, "Received message");
    //JSONObject jsonObj = null;

    String datastr = intent.getExtras().getString("message");
    String message = "";
    if(datastr!=null)
        message = datastr;
    else
        message = getString(R.string.gcm_message);
    displayMessage(context, message);
    // notifies user
    generateNotification(context, message);
}

不过,我无法从意图得到MESSAGEID。我已搜查官方教程和其他论坛,但我没有得到答案。因此我无法验证客户端是否已收到该消息或没有。谢谢你的帮助。

However, I can not get messageId from the intent. I have searched official tutorial and other forums but I didn't get an answer. Thus I can not verify whether the client have received this message or not. Thank you for your help.

推荐答案

此消息ID不传递到客户端。如果你希望能够确认的消息传递,您可以将自己的ID分配给GCM消息,有效载荷内传递。然后,客户端可以该ID发送回服务器来确认交付

This message ID is not passed to the client. If you want to be able to acknowledge message delivery, you can assign your own ID to the GCM message, and pass it within the payload. Then the client can send that ID back to the server to acknowledge delivery.

这篇关于如何从接收端GCM得到MESSAGEID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆