Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

View won't go away

$
0
0

I'm trying to use Facebook login with Xamarin.Forms and I've found that the only way seems to use Xamarin.Auth first on a platform-specific basis to get the auth token (there doesn't seem to be a forms-compatible way?).

I am trying to use @jsauve's example from http://forums.xamarin.com/discussion/19021/using-xamarin-auth-with-xamarin-forms but the Facebook web view simply will not close... it just keeps sticking around no matter what i do. I've even tried to kill it from the iOS project code directly in the completed handler using various methods (one of which is below) but nothing will work... I just can't get rid of it.

Does anyone have any clues what might be wrong?

public class LoginPageRenderer : PageRenderer
{

    public override void ViewDidAppear (bool animated)
    {
        base.ViewDidAppear (animated);

        var vc = ViewController;

        var auth = new OAuth2Authenticator (
            clientId: "fake9749346847827", // your OAuth2 client id
            scope: "", // the scopes for the particular API you're accessing, delimited by "+" symbols
            authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"), // the auth URL for the service
            redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html")); // the redirect URL for the service

        var ui = auth.GetUI();

        auth.Completed += (sender, eventArgs) => {
            // We presented the UI, so it's up to us to dimiss it on iOS.
            vc.DismissViewController(false, null);

         //App.SuccessfulLoginAction.Invoke();

            if (eventArgs.IsAuthenticated) {
                // Use eventArgs.Account to do wonderful things
                App.SaveToken(eventArgs.Account.Properties["access_token"]);
            } else {
                // The user cancelled
            }
        };



        vc.PresentViewController (ui, true, null);

    }
}

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>