androidgoogle-cloud-messagingmessageid

How to get messageId from gcm on receiver side


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

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);
}

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.


Solution

  • 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.