static async Task <WebAuthenticatorResult> PlatformAuthenticateAsync(Options 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.GetCredentialsAsync(); if (creds == null) { return(null); } var idToken = new NSString(creds.IdentityToken, NSStringEncoding.UTF8).ToString(); var authCode = new NSString(creds.AuthorizationCode, NSStringEncoding.UTF8).ToString(); var name = NSPersonNameComponentsFormatter.GetLocalizedString(creds.FullName, NSPersonNameComponentsFormatterStyle.Default, 0); var appleAccount = new WebAuthenticatorResult(); appleAccount.Properties.Add("id_token", idToken); appleAccount.Properties.Add("authorization_code", authCode); appleAccount.Properties.Add("state", creds.State); appleAccount.Properties.Add("email", creds.Email); appleAccount.Properties.Add("user_id", creds.User); appleAccount.Properties.Add("name", name); appleAccount.Properties.Add("realuserstatus", creds.RealUserStatus.ToString()); return(appleAccount); }
static Task PlatformShowRequestAsync(ShareRequestBase request, List <NSObject> items) { var window = Platform.GetCurrentWindow(); var view = window.ContentView; var rect = request.PresentationSourceBounds.AsCGRect(); rect.Y = view.Bounds.Height - rect.Bottom; var picker = new NSSharingServicePicker(items.ToArray()); picker.ShowRelativeToRect(rect, view, NSRectEdge.MinYEdge); return(Task.CompletedTask); }