Skip to content
This repository has been 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

Closed
yakuninv opened this issue Sep 8, 2017 · 4 comments

Comments

@yakuninv
Copy link

yakuninv commented Sep 8, 2017

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

@yakuninv yakuninv 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 Sep 8, 2017
@culebras
Copy link

culebras commented Sep 8, 2017

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.

@bytefish
Copy link
Owner

bytefish commented Sep 9, 2017

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

@culebras
Copy link

culebras commented Sep 9, 2017

Yes, sure!

bytefish pushed a commit that referenced this issue Sep 9, 2017
bytefish pushed a commit that referenced this issue Sep 9, 2017
Links added
bytefish pushed a commit that referenced this issue Sep 9, 2017
@bytefish
Copy link
Owner

bytefish commented Sep 9, 2017

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

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

@bytefish bytefish closed this as completed Sep 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants