Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8273951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:36:20+00:00 2026-06-08T07:36:20+00:00

Following the last section in the GCM: Getting Started guide, there’s some book-keeping to

  • 0

Following the last section in the GCM: Getting Started guide, there’s some book-keeping to be done after receiving the results.

Quoting from the guide:

It’s now necessary to parse the result and take the proper action in the following cases:

  • If the message was created but the result returned a canonical registration ID, it’s necessary to replace the current registration
    ID with the canonical one.
  • If the returned error is NotRegistered, it’s necessary to remove that registration ID, because the application was uninstalled from
    the device.

Here’s a code snippet that handles these 2 conditions:

if (result.getMessageId() != null) {
 String canonicalRegId = result.getCanonicalRegistrationId();
 if (canonicalRegId != null) {
   // same device has more than on registration ID: update database
 }
} else {
 String error = result.getErrorCodeName();
 if (error.equals(Constants.ERROR_NOT_REGISTERED)) {
   // application has been removed from device - unregister database
 }
}

The guide above refers to a single result, and not to the multicast case.
I’m not sure how to handle the multicast case:

    ArrayList<String> devices = new ArrayList<String>();

    for (String d : relevantDevices) {
        devices.add(d);
    }

    Sender sender = new Sender(myApiKey);
    Message message = new Message.Builder().addData("hello", "world").build();
    try {
        MulticastResult result = sender.send(message, devices, 5);

        for (Result r : result.getResults()) {
            if (r.getMessageId() != null) {
                String canonicalRegId = r.getCanonicalRegistrationId();
                if (canonicalRegId != null) {
                    // same device has more than on registration ID: update database
                    // BUT WHICH DEVICE IS IT?
                }
            } else {
                String error = r.getErrorCodeName();
                if (error.equals(Constants.ERROR_NOT_REGISTERED)) {
                    // application has been removed from device - unregister database
                    // BUT WHICH DEVICE IS IT?
                }
            }
        }
    } catch (IOException ex) {
        Log.err(TAG, "sending message failed", ex);
    }

I submit a list of devices, and receive back a list of results.
The Result object doesn’t contain the registration id, but only a canonical id if the first is obsolete.
It is undocumented if the two lists are co-related (ie. preserves order and size).

How can I be sure which result refer to which device?

— UPDATE

I’ve pasted a snippet of the solution in a separate answer below

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:36:23+00:00Added an answer on June 8, 2026 at 7:36 am

    The results are in the order of your registration_id array that you sent to GCM server. e.g. if your registration_ids are:

    [id1, id4, id7, id8]
    

    Then the results array you get will have same order for id1, id4, id7, and id8.

    You just need to parse each result accordingly, e.g. if the 2nd result has ‘message_id’ and ‘registration_id’ of ‘id9’, you know ‘id4’ is now obsolete and should be replaced by id9.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SOLVED in the last answer im getting following error, dunno where and why? cause
I am currently following along with http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-a-model to get a grasp of MVC 4.
The perldocs say the following about last : last cannot be used to exit
Following from my last question which @Jon Skeet gave me a lot of help
I have the following String First Last <first.last@email.com> I would like to extract first.last
I've tried a variety of combinations, the following being my last attempt: Addtype text/vnd.wap.wml
Following up on my last year's question on documentation, I now want to get
The last line in the following line keeps on generating the warning C4552: '<='
The last log in the following code doesn't work in Firefox. Why? (function() {
I have following CSS: table tbody tr:last-child td { padding-top: 7px; border-bottom: 0; }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.