Search Unity

Swich Google Play Account

Discussion in 'Android' started by Antoine_OSG, Sep 8, 2016.

  1. Antoine_OSG

    Antoine_OSG

    Joined:
    Sep 2, 2016
    Posts:
    43
    Hello,

    I'm trying to implement multiple account management in my game using Unity's Social API.
    When starting the game, I'm detecting the user Google Play ID using Social.localUser.id (after the authenticate method has successfully fired its success callback).
    This works fine, and I'm able to save this ID in my database to retrieve my player's data later. If I delete the app and reinstall it, I'm able to reload my player's progress.

    Now, I'd like to detect that the user has changed his Google Play account in his phone's setting. I've created several accounts, each using a different email address. However, when I switch account in the phone's settings, Social.localUser.id returns the id of the account that first launched the app (even though I killed the app while I was switching accounts).
    The weird thing is that even though the Google Play Games app says PlayerB is connected, my app still pops the native Google Play notification saying "Welcome PlayerA".

    The only way I found to get Social.localUser.id to return the id of the current Google Play Games user is to delete all data of my app.

    I don't really know what the problem is, it appears that it's more something related to Google Play itself rather than Android, but any help would be welcome.

    Has anyone implemented some multi-account support in Unity, or any idea on what my problem could be?

    Thanks in advance.
     
    IgorAherne likes this.
  2. Antoine_OSG

    Antoine_OSG

    Joined:
    Sep 2, 2016
    Posts:
    43
    I think I nailed it.
    It looks like Google Play's behaviour is different from Game Center.
    When a user starts an app on Google Play, it seems that this account is "linked" to the app. No matter what account is logged to the phone, the app will always start with that users profile.
    It means that you need to implement a "log out" button in your app if you want to implement multiple account management in your game.

    Hope it helps...
     
    IgorAherne likes this.
  3. ramioooz

    ramioooz

    Joined:
    Feb 15, 2015
    Posts:
    30
  4. HanSoloYolo

    HanSoloYolo

    Joined:
    May 22, 2017
    Posts:
    19
    What is the Google Logout method called?

    Please share the line of code.
     
    IgorAherne likes this.
  5. Deleted User

    Deleted User

    Guest

    // Sign out of play games
    PlayGamesPlatform.Instance.SignOut();

    // Reset UI
    signInButtonText.text = "Sign In";
    authStatus.text = "";
     
    IgorAherne likes this.