public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options) { if (NativeSafariAuthenticator.ResumeAuth(url.AbsoluteString)) { return(true); } return(false); }
public static async void Login(WebAuthenticator authenticator, Action <WebAuthenticator> fallback) { var ta = authenticator as TwitterAuthenticator; var scheme = $"twitterkit-{ta.ClientId}"; if (!NativeSafariAuthenticator.VerifyHasUrlSchemeOrDoesntRequire(scheme)) { authenticator.OnError($"Unable to redirect {scheme}, Please add the Url Scheme to the info.plist"); return; } var returnUrl = HttpUtility.UrlEncode($"{scheme}://{ta.Identifier}"); var nativeUrl = new NSUrl($"twitterauth://authorize?consumer_key={ta.ClientId}&consumer_secret={ta.ClientSecret}&oauth_callback={returnUrl}"); if (UIApplication.SharedApplication.CanOpenUrl(nativeUrl)) { if ((await UIApplication.SharedApplication.OpenUrlAsync(nativeUrl, new UIApplicationOpenUrlOptions()))) { CurrentAuthenticators[ta.Identifier] = ta; return; } } fallback(authenticator); }