Search Unity

Game Center Log in

Discussion in 'Scripting' started by downhilldan, May 3, 2017.

  1. downhilldan

    downhilldan

    Joined:
    Nov 16, 2016
    Posts:
    90
    Hi All,

    I've tried to implement Game Center into my game using Unity's social API because I need it to save the user's data for IAP's. I have the app in Test Flight but the user is never logged in to Game Center when they start up the app. Is the social API even the right thing to use for Game Center? I have Game Center enabled in the capabilities in Xcode when I export to the App Store and my "user login" script is on a game object that persists through all scenes.

    Here is my code:
    Code (CSharp):
    1. void Start ()
    2.     {
    3.         Social.localUser.Authenticate (ProcessAuthentication);
    4.     }
    5.  
    6.     void ProcessAuthentication (bool success) {
    7.         if (success)
    8.         {
    9.             Debug.Log ("Authenticated, checking achievements");
    10.  
    11.             Social.LoadAchievements (ProcessLoadedAchievements);
    12.         }
    13.         else
    14.             Debug.Log ("Failed to authenticate");
    15.     }
    16.  
    17.     void ProcessLoadedAchievements (IAchievement[] achievements)
    18.     {
    19.         if (achievements.Length == 0)
    20.             Debug.Log ("Error: no achievements found");
    21.         else
    22.             Debug.Log ("Got " + achievements.Length + " achievements");
    23.     }
     
  2. downhilldan

    downhilldan

    Joined:
    Nov 16, 2016
    Posts:
    90
  3. mikael_juhala

    mikael_juhala

    Joined:
    Mar 9, 2015
    Posts:
    247
  4. downhilldan

    downhilldan

    Joined:
    Nov 16, 2016
    Posts:
    90
    There are no errors besides "no achievements found" (I don't have any so that is expected) and it is also saying that it successfully authenticates the user (ill attach the console screenshot). Could my problem be with the achievements? Do you have to have at least one achievement for Game Center to work?
     

    Attached Files:

  5. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Are you testing this in Unity?
     
  6. downhilldan

    downhilldan

    Joined:
    Nov 16, 2016
    Posts:
    90
    Sorry for the late reply.

    Im testing it in Test Flight
     
  7. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I don't know what that means. I was asking if it was Xcode, Unity, or a device, I guess.
    And did you have any luck getting this to work since your last post?
     
  8. downhilldan

    downhilldan

    Joined:
    Nov 16, 2016
    Posts:
    90
    Im testing it through Apple's testing application, Test Flight, on an iPad. So I'm testing on a device. And no, no luck yet :(
     
  9. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Then I'm not sure.
    I never got very far with apple and unity. And after 1 try, I never had the opportunity for more testing. :)

    To answer an older question, I would guess you have to have an achievement for it to work.

    Hope you figure it out - sorry I couldn't be more help.
     
  10. msclower

    msclower

    Joined:
    May 26, 2017
    Posts:
    13
    Late answer but I believe the solution is to create an achievement and maybe scoreboard within GameCenter. Don't have to be used.