I want to link an iOS device to an existing PlayFab account. The account is a recoverable account and the player uses username and password to make the log in.
I call LoginWithPlayFab and after the player is logged in I call GetPlayerCombinedInfonew(). But something is wrong with my code because result.Result.InfoResultPayload.AccountInfo.IosDeviceInfo.IosDeviceId is always null.
Why is it null?
I want to find out if "IosDeviceId" is already linked to the player's account or not. If not, then I want to add the current device Id(PlayerDeviceId) to the player's account if this device Id is not yet linked to another player's account.
What happens if the device Id(PlayerDeviceId) is already linked to another player's account? Is it possible to unlink the device Id from that account and link it afterwards to this account?
How can I unlink a device Id?
What happens if the device Id(PlayerDeviceId) is already linked to another player's account and if I use ForceLink = true in LinkIOSDeviceID?
public async void GetPlayerCombinedInfonew() { await GetPlayerCombinedInfo(); } private async Task GetPlayerCombinedInfo() { var result = await PlayFabClientAPI.GetPlayerCombinedInfoAsync(new GetPlayerCombinedInfoRequest() { PlayFabId = PlayerPlayFabID, InfoRequestParameters = new GetPlayerCombinedInfoRequestParams() { GetUserAccountInfo = true } }); if (result.Error != null) Console.WriteLine(result.Error.GenerateErrorReport()); else { if (result.Result.InfoResultPayload.AccountInfo.IosDeviceInfo.IosDeviceId == PlayerDeviceId) Console.WriteLine("DeviceId already bound to this account: " + result.Result.InfoResultPayload.AccountInfo.Username); else //Bind the device to this account if the device is not yet bound to another player's account: await LinkiOSDeviceID(); } } private async Task LinkiOSDeviceID() { var result = await PlayFabClientAPI.LinkIOSDeviceIDAsync(new LinkIOSDeviceIDRequest() { DeviceId = PlayerDeviceId, ForceLink = false }); if (result.Error != null) Console.WriteLine(result.Error.GenerateErrorReport()); else { if (result.Result.ToString() == "true") Console.WriteLine("Linking DeviceId to this account was successful."); else Console.WriteLine("Linking DeviceId to this account was not successful."); } }