question

maria-1 avatar image
maria-1 asked

Leaderboard score is not kept if android app is closed and than re-opened

Hello, I am building a android app that utilizes leaderboards. When the player logs in I have the following called

    public void SignIn(){
     
         GetStats();
         GetLeaderboard();
         SendLeaderboard();
         GetStatsYearly();
         GetLeaderboardYearly();
         SendLeaderboardYearly();
     }

I have noticed that often times at the end of the game, the majority of peoples score is 0 which is the default starting score. The only thing I can think that would be causing this is that the player gets "logged out" if they close the app on the tablet and then tries to go back into the app and continue. Is there anyway to prevent this from happening if this is the case?

Leaderboards and Statistics
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

·
Neils Shi avatar image
Neils Shi answered

You can save the login credentials locally after player sign in, the session ticket and entity token last for 24 hours, and the player can access the PlayFab service if the credentials is valid. Alternatively, you can use the API LoginWithAndroidDeviceID or LoginWithCustomID and have the player log in every time they launch the app. The anonymous login offers the players a fully automated login process – they don’t need to type in any credentials to sign in. However, you should also make sure that each player account has at least one recoverable login mechanism. For more info, please refer to Login basics and best Practices - PlayFab | Microsoft Learn. In addition, you may also need to make sure that your app is able to properly save player’s score when players close the app. If your app doesn't save score correctly, it may result in the upload of incorrect scores.

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.