HomeiOS Developmentc# - How can I distinguish a participant signed in anonymously from...

c# – How can I distinguish a participant signed in anonymously from a participant signed in with Apple Signal In?


In response to the docs, you’ll want to do the next:

  • Check in Anonymously such as you’re doing

  • Immediate the participant to set off the Apple Sport Heart sign-in and get the ID verification parameters from GameKit. Then, name the LinkWithAppleGameCenterAsync API to hyperlink the participant to the Apple Sport Heart teamPlayerID.

async Process LinkWithAppleGameCenterAsync(string signature, string teamPlayerId, string   publicKeyURL, string salt, ulong timestamp)
{
    strive
    {
        await AuthenticationService.Occasion.LinkWithAppleGameCenterAsync(signature, teamPlayerId, publicKeyURL, salt, timestamp);
        Debug.Log("Hyperlink is profitable.");
    }
    catch (AuthenticationException ex) when (ex.ErrorCode == AuthenticationErrorCodes.AccountAlreadyLinked)
    {
        // Immediate the participant with an error message.
        Debug.LogError("This consumer is already linked with one other account. Log in as a substitute.");
    }
    catch (AuthenticationException ex)
    {
        // Examine error code to AuthenticationErrorCodes
        // Notify the participant with the correct error message
        Debug.LogException(ex);
    }
    catch (RequestFailedException ex)
    {
        // Examine error code to CommonErrorCodes
        // Notify the participant with the correct error message
        Debug.LogException(ex);
    }
}

One other factor, there are two forms of IDs on iOS, the teamPlayerID and the gamePlayerID . You in all probability want to make use of the teamPlayerID for leaderboards. It is because the gamePlayerID is for safeguarding the participant’s privateness and it will not at all times return the identical worth.

And lastly, to verify if the participant is already signed in utilizing Apple, use the next code

public bool IsLinkedWithApple()
{
    var playerInfo = AuthenticationService.Occasion.PlayerInfo;

    // Verify if playerInfo exists and comprises any identities
    if (playerInfo != null && playerInfo.Identities.Depend > 0)
    {
        // Verify if any of the linked identities are of sort "apple"
        return playerInfo.Identities.Any(i => i.TypeId.Comprises("apple"));
    }
    return false; // No participant data or no identities linked
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments