CKError retry after seconds

Need a new feature? Wish the plugin behaved differently? Leave us some thoughts about what you'd like to see changed.
pistoleta
Posts: 11
Joined: Fri Nov 06, 2020 12:11 pm

CKError retry after seconds

Post by pistoleta »

I was wondering how does the API tell us whenever the server has answered a CKError which provides information to retry after x seconds.
As I see in the NSError class we have:
  • (long) "Code:"+error.Code + ", " +
  • (string) "/ LocalDesc:"+error.LocalizedDescription + ", " +
  • (string) "/ FailReason:" + error.LocalizedFailureReason + ", " +
  • (string) "/ RecovSuggest: " + error.LocalizedRecoverySuggestion + ", " +
  • (string) "/ HelpAnchor: " + error.HelpAnchor;
So I was wondering if we ever get one answer like serverBusy or others that I've seen that return the amount of seconds you should wait to retry,
where do we gather it?

admin
Site Admin
Posts: 24
Joined: Thu Mar 19, 2020 8:52 pm

Re: CKError retry after seconds

Post by admin »

Apple provides this by means of a "userInfo" dictionary on the NSError object. It's a dictionary where the keys are strings, and the values are untyped.

This dictionary is not currently exposed in the plugin, as there isn't a great way to pass a dictionary with untyped values from C to C#. It's not impossible per-se, but the work involved is quite complex. Part of the issue is that what is actually in this dictionary changes depending on what the error is.

Been thinking about it regardless. One quick solution is to serialize the entire dictionary as a string and send this up to Unity for inspection. As easy as that would be it's not very elegant. Another is to expose a series of "getIntForKey", "getStringForKey" methods that require the end-user to know the type of the data they need for a given key (which is documented)

The third...well I don't want to think about the third, it's almost more complicated than every other bit of the plugin combined. I'm leaning toward the second option.

pistoleta
Posts: 11
Joined: Fri Nov 06, 2020 12:11 pm

Re: CKError retry after seconds

Post by pistoleta »

I find the second option quite easy for us to use and if we have the keys in the official documentation even better.

admin
Site Admin
Posts: 24
Joined: Thu Mar 19, 2020 8:52 pm

Re: CKError retry after seconds

Post by admin »

Sounds good. I Will start work on implementing the second option today. Out of curiosity, what is the error message you are receiving?

pistoleta
Posts: 11
Joined: Fri Nov 06, 2020 12:11 pm

Re: CKError retry after seconds

Post by pistoleta »

Not receiving any error message of that kind.
But I have been watching all the WWDC videos from the '14 one and on error handling they talk about how to handle them well using this method,
and since it may happen in a near future I would rather to be ready.

Post Reply