Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

GameCenter always returning false on Authenticate()

Discussion in 'Scripting' started by hjeldin, Feb 10, 2015.

  1. hjeldin

    hjeldin

    Joined:
    Jan 7, 2013
    Posts:
    8
    Hey everyone,
    i'm trying to wrap my head around iOS social api/gamecenter and I have the following, and frankly quite simple, code:

    Code (csharp):
    1.  
    2. Social.localUser.Authenticate (success => {
    3.     if (success) {
    4.         Debug.Log ("Authentication successful");
    5.         string userInfo = "Username: " + Social.localUser.userName +
    6.             "\nUser ID: " + Social.localUser.id +
    7.                 "\nIsUnderage: " + Social.localUser.underage;
    8.         Debug.Log (userInfo);
    9.     }
    10.     else
    11.         Debug.Log ("Authentication failed");
    12. });
    13.  
    I created the app on iTunesConnect, added GameCenter on the website, added the reference to the Xcode project, created a leaderboard and some achievements.I'm logged with my test user and I'm able to purchase in-apps in the sandbox environment, so i guess that configuration is not the issue here.
    Every time I try to authenticate, it results in a "Authentication Failed".
    I guess the main issue here is the complete lack of informations returned by Authenticate.
    Are there any known issues with Social.localUser.Authenticate? Is there a way to get more info, instead of a laconic "false"?

    Thanks,
    Riccardo.
     
  2. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,077
    The GC stuff was changed recently - you need to have the testflight app installed on your phone before it'll authenticate properly (which is pretty annoying!). Once the app is installed I think you need to go to the settings->testflight and enable sandbox mode there too.
     
  3. hjeldin

    hjeldin

    Joined:
    Jan 7, 2013
    Posts:
    8
    Ok, I installed the testflight app; unfortunately i haven't submitted my app to the store yet and i'm testing through ad hoc deploy so i can't see my app listed in testflight. I haven't found the sandbox mode either.
    Anyway, i gave it a shot, but still nothing to do, "Authentication failed" as always.
     
  4. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,077
    Sorry, I should have said that you don't need to have your app submitted or testing through testflight - you just need to have the testflight app installed for the GC sandbox to work.

    I also made a mistake when I said you should go to 'settings->testflight'. I meant to say that you should go to 'settings->game center' and scroll to the bottom. When testflight is installed it gives you additional 'developer' options like sandbox etc... which you can switch on.
     
  5. hjeldin

    hjeldin

    Joined:
    Jan 7, 2013
    Posts:
    8
    Wow, i feel very dumb now. Thank you very much, it works like a charm!
     
  6. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,077
    No probs, happened to me too - my code used to work and then it stopped and I couldn't figure it out.
     
  7. afrokick

    afrokick

    Joined:
    May 13, 2011
    Posts:
    6
    It doesn't work for me(iOS 8.2).

    + switched on Sandbox in Settings->GameCenter

    Any ideas?

    UPD Tested on 8.1.2 - works! On 8.2 - not.
     
    Last edited: Mar 16, 2015
  8. afrokick

    afrokick

    Joined:
    May 13, 2011
    Posts:
    6
    On IPad mini(8.2) game center works fine. But doesn't work on Iphone 5(8.2) wtf?
     
  9. Frima_FXVezina

    Frima_FXVezina

    Joined:
    Apr 23, 2015
    Posts:
    6
    Quite a bit late to the party, but this was the cause of the problem on my side:

    "IMPORTANT: do not cancel the Game Center login 3 times while using the sandbox servers! This will completely disable Game Center on your device and it is an irrecoverable state. (...) The only way to use your device with the sandbox servers after doing that is to wipe all device settings in the Settings.app: General > Reset > Reset All Settings."

    Behaviour was: Social.LocalUser.Authenticate was silently failling since we refused to login the first couple boots. Sandbox option also had to be checked after resetting the device's settings.

    Hope this can help!
     
  10. dimitroff

    dimitroff

    Joined:
    Apr 3, 2013
    Posts:
    129
    Wow, Unity 5.3.3f and this bug is still around, I guess Unity should handle this problem, not receiving a response from Social.localUser.authenticate is a pretty bad bug, which is hard to debug. In our case we have implemented a fallback for the response, but this brings other problems, for example, some players just may take some time to type their password.
     
  11. noamgat

    noamgat

    Joined:
    Nov 22, 2009
    Posts:
    125
    Any update on this from unity? We are encountering the issue as well.
     
  12. MixMasterRickyC

    MixMasterRickyC

    Joined:
    Oct 2, 2012
    Posts:
    3
    Has something changed in GameCenter?

    Previously the Social.localUser.Authenticate callback would fire if the state of GameCenter changed.

    For example,
    1) Start you application
    2) Cancel the Sign in to GameCenter
    3) Minimise the application
    4) iOS settings > Sign into GameCenter
    5) Return to the application

    The callback is no longer fired so we can't tell that the user is now signed back in. This also happens if they start the app, sign in to GC, minimise the app and sign out of GC.