Search Unity

Apple Sign in - get email

Discussion in 'iOS and tvOS' started by swifter14, Jan 24, 2020.

  1. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    165
    I'm using Unity's SignInwIthApple, and it seems to log in fine on mobile so far so great
    The problem is that I want to take the user's email or some sort of identification in order to save them in my database, but when I try this-
    args.userInfo.email - I get an empty string.
    If I try args.userInfo.idToken I get a long token, which means args.userInfo is not null, but why doesn't it contain the email? is there another way to get email or userID from apple users?
    args.credentialState returns "Revoked"

    Here it the function and I try to extract user information after the successful login, it's the default script from the apple sign in asset-
    private static void LoginCompletedCallback(int result, [MarshalAs(UnmanagedType.Struct)]UserInfo info)
    {

    var args = new CallbackArgs();
    if (result != 0)
    {
    args.userInfo = new UserInfo
    {
    idToken = info.idToken,
    displayName = info.displayName,
    email = info.email,
    userId = info.userId,
    userDetectionStatus = info.userDetectionStatus


    };
    Debug.Log("args.userInfo.email);
    Debug.Log("2args.userInfo=" + args.userInfo.idToken);
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    IIRC, you have to opt-in for e-mail during sign-in in order to get it. By default you'll only get ID.
     
  3. hantengx

    hantengx

    Joined:
    Mar 13, 2017
    Posts:
    10
    have a same problem, displayName alse is a empty string. is it also opt?
     
  4. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Why don't you use the info.userId field?
     
  5. kidzooly

    kidzooly

    Joined:
    Jan 23, 2016
    Posts:
    26
    Can you explain me how do I opt in for email ?