question

andrew@spryfox.com avatar image
andrew@spryfox.com asked

what happens when the app has been backgrounded for a long time?

Hi folks,

This is a hypothetical question, I've not seen any issues, but I was wondering what happens in the following scenario:

- player launches the app
- app authenticates (in our case, mostly frictionlessly)
- player backgrounds the app
- player ignores phone or tablet for days or even weeks
- player reopens tablet, which foregrounds app
- app tries to interact with playfab (in our case, mostly sending a cloud script request)

Is any reauthentication handled seemlessly? Or do we need to keep an eye out for a specific error and ask for reauthentication? If the latter are there any recommendations for best practices?

10 |1200

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

Andy avatar image
Andy answered

The SessionTicket we use to authenticate logged in players expires after 24 hours. If it's been longer than that, you'll see failures on any subsequent client API calls and you'll need to login again to acquire a new SessionTicket. This re-login does not happen automatically.

It's worth noting that the entity APIs change this paradigm a little bit. Instead of using a global SessionTicket, they utilize a per-entity EntityToken. Each EntityToken returns its own expiration time (if any) when created.

2 comments
10 |1200

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

andrew@spryfox.com avatar image andrew@spryfox.com commented ·

Can you give me more info? How do I know if a session ticket has expired, without just starting a timer? Will PlayFabClientAPI.IsClientLoggedIn() go false? What kind of errors will I see if I attempt a cloudscript call with an invalid session ticket?

0 Likes 0 ·
Andy avatar image Andy ♦♦ andrew@spryfox.com commented ·

Certainly. You'd get a 401 - Unauthorized response, with a 1074 - Not Authenticated error on any client call that requires a SessionTicket (most of them). The IsClientLoggedIn() call will not reflect the expired ticket state and will continue to return true.

Best practices here would be to silently re-login using device identifier periodically so that you don't find yourself in this state. If it's truly been multiple days since the player last switched focus to your app, then that's something I'd recommend you track and go back through your login flow, ideally silently.

0 Likes 0 ·
Damian Rajamanie avatar image
Damian Rajamanie answered

I need to test this. Waiting for 24 hours to see if my re authentication code is working fine within my game, whilst it's running and there is nothing else erroneous going on is going to make testing extremely hard. I cannot find anywhere that allows us to invalidate the ticekt, I don't mind where, I'll make a debug button, the Dashboard (GameManager), cloud script whatever, but how do I FORCE INVALIDATE it so that I can get the failed calls and check that my code is behaving without waiting for 24 hours on each run until I get it right?

Cheers

1 comment
10 |1200

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

brendan avatar image brendan commented ·

You don't have to invalidate every ticket. A single expired ticket would suffice for your testing.

0 Likes 0 ·

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.