question

Karl Loveridge avatar image
Karl Loveridge asked

How do I know I'm logged in?

So I'm logging in on my device using this code:

void LoginIOS()

        {

            LoginWithIOSDeviceIDRequest request = new LoginWithIOSDeviceIDRequest();

            request.TitleId = PlayFabSettings.TitleId;

            request.DeviceId = SystemInfo.deviceUniqueIdentifier;

            request.CreateAccount = true;

            PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginSuccess, OnLoginFailure);

        }

And it works. But thats on startup of my game. Lets say 20 minutes later the player wants to purchase something. How do I verify that I still have connectivity? What if the player suddenly drops service? Whats the best practice to test connectivity? It seems risky to always assume I have connectivity.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Testing connection isn't really valuable, since you could lose connection immediately after testing. What you should do is always check for the error responses to any attempt to call a Web API. If you get an error telling you the session ticket is invalid, that means you need to re-sign the player back in. If you get a timeout or other connection issue error back, use an exponential backoff to schedule retrying the call, so that you don't unnecessarily chew through the player's battery (for a mobile game).

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.