Sitelet https://github.com/bytefish/FcmJava/issues/30
Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Does order of FcmMessageResultItems in the FcmMessageResponse corresponds to the order of registrationIds provided in the constructor of NotificationMulticastMessage #30

Description

@yakuninv

Hello,

As part of error handling when sending NotificationMulticastMessage, I need to map erroneous FcmMessageResultItem to the token that caused an error. Ex: typical use case is to remove not registered tokens from my db.

Can i rely on the order of FcmMessageResultItems in the FcmMessageResponse? Does it correspond to the order of registrationIds provided in the constructor of NotificationMulticastMessage?

If this is not true, how can I do such mapping?

Thanks in advance
Sla

Activity

  1. changed the title [-]Does order of FcmMessageResultItems in the FcmMessageResponse corresponds the order of registrationIds provided in the constructor of NotificationMulticastMessage[/-] [+]Does order of FcmMessageResultItems in the FcmMessageResponse corresponds to the order of registrationIds provided in the constructor of NotificationMulticastMessage[/+] on Sep 8, 2017
  2. culebras commented on Sep 8, 2017

    @culebras

    Hello Slav (I am Fran, from Brno office),

    Take a look into this thread, I think it will answer your question (looks like the order is the same):

    https://stackoverflow.com/questions/40518125/wich-fcm-registration-id-has-failed-when-targeted-for-multiple-registration-ids

    • So for the FcmMessageResultItems with errorCode equals to NotRegistered you will want to remove those tokens for your DB.
    • For the FcmMessageResultItems with errorCode equals to Unavailable maybe you will want to resend the message for those tokens.
    • For the FcmMessageResultItems with registration_id not null, you will want to update the tokens in your DB (I think that the new registration_id can be obtained in this library from FcmMessageResultItem.getCanonicalRegistrationId).
    • Etc.

    But, regarding to the Canonical IDs, you have to consider this:

    https://stackoverflow.com/questions/45018247/android-google-fcm-canonical-ids-how-to-reproduce-in-non-production-or-tests

    Because it looks like that:

    In FCM, it seems the Canonical IDs are no longer used (or at the very least extremely rarely) because of how the Instance ID service works. To put it simply, the service works that there would only be one valid token per App Instance.

    So the updating of tokens in your DB for those tokens which are refreshed in FCM cloud would be mostly done in the method onTokenRefresh() in your Android client application (in this method is where the device should send the token to your DB the first time the device register itself to the FCM and also when the token is refreshed in FCM).

    So, it seems that is not very likely that you are going to receive FcmMessageResultItem with registration_id not null, but anyway, it is good idea to also expect this and update the canonical token of those FcmMessageResultItem.

  3. bytefish commented on Sep 9, 2017

    @bytefish
    Owner

    Thanks @culebras for the very detailed writeup! Can I add this question and answer to the README? Because I think many people wonder how to interpret the FCM responses correctly. 👍

  4. culebras commented on Sep 9, 2017

    @culebras

    Yes, sure!

  5. added 3 commits that reference this issue on Sep 9, 2017
  6. bytefish commented on Sep 9, 2017

    @bytefish
    Owner

    I have updated the README and included this discussion. Thanks for your valuable summary!

    Please reopen this ticket, if there are any additional questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions