Search Unity

GameCircle localUser data empty through Social API

Discussion in 'Android' started by ben-tmg, Nov 7, 2014.

  1. ben-tmg

    ben-tmg

    Joined:
    Jan 10, 2014
    Posts:
    2
    I'm trying to use the Social API interface to Amazon's GameCircle SDK.
    The problem is that after I've logged in (I see the little popup at the bottom of the screen) the localUser data is all empty.

    I see this in both my own code and when using the SocialSample.
    When I use Amazon's main sample the data is present.

    Has anybody else seen this? Is there a fix/work around?
     
  2. ben-tmg

    ben-tmg

    Joined:
    Jan 10, 2014
    Posts:
    2
    After further investigation I found that the GameCircle Social API implementation has some bugs.
    AGSSocialLocalUser derives from AGSSocialUser but AGSSocialLocalUser has a public static member variable 'player' whereas AGSSocialUser has a private member variable also called 'player'.
    The player initialization code sets the public static variable but all the methods reference the private variable, this means that all calls to Social.localUser.id etc. will return empty strings (because it defaults to BlankPlayer).

    To make Social.localUser work as expected you need to change AGSSocialLocalUser to implement IUserProfile directly and not rely on AGSSocialUser.

    This still won't work because of the way GameCircle is initialized.

    Social.Active.Authenticate does initialize the underlying system but doesn't call RequestLocalPlayer. To make this work you will need to change GameCircleSocial:Authenticate to save the callback it is given and make a call to RequestLocalPlayer after the system has initialized.

    i.e. Change GameCircleSocial.cs

    Code (CSharp):
    1.  
    2. private Action<bool>  userAuthenticationCallback;
    3.  
    4. public void Authenticate(ILocalUser user, System.Action<bool> callback) {
    5.         // Forward the AGSClient callbacks to the passed in callback.
    6.         userAuthenticationCallback = callback;
    7.         authenticationCallback = Authenticated;
    8.         // If using GameCircle with the Unity Social API,
    9.         // initialize it with leaderboards and achievements, but not whispersync.
    10.         AGSClient.Init(/*Leaderboards*/true,/*Achievements*/true,/*Whispersync*/false);
    11.     }
    12.  
    13.     private void Authenticated(bool success)
    14.     {
    15.         //Authenticated correctly, grab user data
    16.         if(success)
    17.             RequestLocalPlayer(userAuthenticationCallback);
    18.         else //bubble failure up to user
    19.             userAuthenticationCallback(success);
    20.     }
    21.  
    After making both of these changes then social will initialize correctly and you can use GameCenter, Google Play Services and Game Circle from the same code base (which was the point in the first place!)