question

yogev avatar image
yogev asked

Getting android device id

Hey, I am using this https://gist.github.com/TarasOsiris/9270285 in order to get the android id and then using LoginWithAndroidDeviceID

should I encrypt the ID and then send it to Playfab or is it safe as is?

Another thing If the user deletes the app and reinstalls it how can I log him to the same account?

my code :

         string android_id = AndroidIdRetriever.Retrieve();
         if (!string.IsNullOrEmpty(android_id))
         {
    
             PlayFabClientAPI.LoginWithAndroidDeviceID(new LoginWithAndroidDeviceIDRequest
             {
                 AndroidDeviceId = AndroidIdRetriever.Retrieve(),
                 TitleId = PlayFabSettings.TitleId,
                 CreateAccount = true
             }, result =>
             {
    
             }, OnPlayfabuthFailed);
         }

And the last thing is when they restart start the game they have one button to start playing, how can I know with what sign-in option they did last time ? (I have Facebook and Google or anonymous) and then I want to try to log them up again without them clicking on a button something like auto remember me

thank you !!

apis
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

Xiao Zha avatar image
Xiao Zha answered

>> should I encrypt the ID and then send it to Playfab or is it safe as is?

Since PlayFab require that SSL be used for all API calls to the service, specifically to prevent (as much as possible) man-in-the-middle attacks, it is ok for you to send the id as is.

>> Another thing If the user deletes the app and reinstalls it how can I log him to the same account?

Under normal circumstances, the android device id won’t change if the user only deletes the app and reinstalls it. But since LoginWithAndroidDeviceId is anonymous, the method can uniquely identify a device, but contain no recoverable information about the player. If the player loses or breaks their device, the account is lost, and may be difficult to recover. In most cases the account is simply orphaned and not retrievable. So, once the anonymous login is complete ,it is recommended to provide the option to add recoverable login credentials, and provide some explanation regarding the benefits.

>> And the last thing is when they restart start the game they have one button to start playing, how can I know with what sign-in option they did last time ? (I have Facebook and Google or anonymous) and then I want to try to log them up again without them clicking on a button something like auto remember me.

As I understand , you want to implement the silent login with Facebook and Google. But, as you can see in Client/LoginWithFacebook and Client/LoginWithGoogleAccount or Client/LoginWithGooglePlayGameService API, PlayFab need the AccessToken or ServerAuthCode returned from Facebook or Google for the login. So, the actual question here is how to silently get AccessToken from Facebook or ServerAuthCode from Google. I'm not an expert on this, I'd suggest you seek help from Facebook or Google.

If Facebook and Google do not support silent login, you could only use android device ID to implement the silent login.

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.

yogev avatar image yogev commented ·

Hey, thank you so much !! I know how to get the Facebook token but how can I know with what the user connected last time? Google Play/facebook should I save it with PlayerPref or is there a playfab function?

and should I check if the player PlayFabClientAPI.IsClientLoggedIn ? or should I get the token again each time he restart the game?

thank you

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha yogev commented ·

PlayFab doesn’t provide such feature for you to record the login options of player, you could save the player's login option locally and then read and use it the next time player log in. Also, PlayFabClientAPI.IsClientLoggedIn is used to check whether the client has logged in and once the player restarts the application, this will return false. In addition, since player logged in PlayFab will get a SessionTickets and EntityToken( they do last for 24 hours) for API calling, you could save them locally. In this case, you don't have to get the access token to sign in the player every time player restarts the application - but it is a good idea to always check the response from each API call, to see if the ticket has expired and needs to be updated.

0 Likes 0 ·