Version: 2020.2
LanguageEnglish
  • C#

IUserProfile.id

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public string id;

Description

This user's global unique identifier.

For devices running iOS version 12.4 and later, IUserProfile.id returns GKPlayer.teamPlayerID.

For devices running iOS version 12.3 and earlier, IUserProfile.id returns GKPlayer.playerID.

Use IUserProfile.id instead of UserProfile.legacyId. Only use UserProfile.legacyId if you need to access GKPlayer.playerID to migrate player data in your existing project.

using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;

public class ExampleScript : MonoBehaviour { void Start() { Social.localUser.Authenticate(success => { if (success) { Debug.Log("Authentication successful");

UserProfile user = Social.localUser as UserProfile;

string userInfo = "Username: " + user.userName + "\nCurrent User ID: " + user.id + "\nLegacy User ID: " + user.legacyId;

Debug.Log(userInfo); } else Debug.Log("Authentication failed"); }); } }