static async Task <WebAuthenticatorResult> PlatformAuthenticateAsync(AppleSignInOptions options) { if (DeviceInfo.Version.Major < 13) { throw new FeatureNotSupportedException(); } var provider = new ASAuthorizationAppleIdProvider(); var req = provider.CreateRequest(); authManager = new AuthManager(Platform.GetCurrentWindow()); var scopes = new List <ASAuthorizationScope>(); if (options.IncludeFullNameScope) { scopes.Add(ASAuthorizationScope.FullName); } if (options.IncludeEmailScope) { scopes.Add(ASAuthorizationScope.Email); } req.RequestedScopes = scopes.ToArray(); var controller = new ASAuthorizationController(new[] { req }); controller.Delegate = authManager; controller.PresentationContextProvider = authManager; controller.PerformRequests(); var creds = await authManager.Credentials; if (creds == null) { return(null); } var appleAccount = new WebAuthenticatorResult(); appleAccount.Properties.Add("id_token", new NSString(creds.IdentityToken, NSStringEncoding.UTF8).ToString()); appleAccount.Properties.Add("email", creds.Email); appleAccount.Properties.Add("user_id", creds.User); appleAccount.Properties.Add("name", NSPersonNameComponentsFormatter.GetLocalizedString(creds.FullName, NSPersonNameComponentsFormatterStyle.Default, NSPersonNameComponentsFormatterOptions.Phonetic)); appleAccount.Properties.Add("realuserstatus", creds.RealUserStatus.ToString()); return(appleAccount); }
static Task <WebAuthenticatorResult> PlatformAuthenticateAsync(AppleSignInOptions options) => throw ExceptionUtils.NotSupportedOrImplementedException;
public static Task <WebAuthenticatorResult> AuthenticateAsync(AppleSignInOptions options = null) => PlatformAuthenticateAsync(options ?? new AppleSignInOptions());