locked
Facebook login failed in XAMARIN webview RRS feed

  • Question

  • User308022 posted

    I am making webview of working website, but in the webview the facebook login doesn't work. I enter email, pass, and when i click sign in, it retries me to the login page.. Someone help me. Here is my code:

    WebView web_view;
    
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
    
        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);
        web_view = FindViewById<WebView>(Resource.Id.webview);
        web_view.Settings.JavaScriptEnabled = true;
    
        var cookieManager = CookieManager.Instance;
        cookieManager.SetAcceptCookie(true);
    
        web_view.SetWebViewClient(new HelloWebViewClient());
        web_view.LoadUrl("[MY LINK]");
    
    }
    
    
    public override bool OnKeyDown(Keycode keyCode, Android.Views.KeyEvent e)
    {
        if (keyCode == Keycode.Back && web_view.CanGoBack())
        {
            web_view.GoBack();
            return true;
        }
    
        return base.OnKeyDown(keyCode, e);
    }
    
    
    public class HelloWebViewClient : WebViewClient
    {
    
        public override bool ShouldOverrideUrlLoading(WebView view, string url)
        {
            Uri uri = new Uri(url);
    
            var cookieManager = CookieManager.Instance;
            var cookieContainer = new CookieContainer();
            cookieContainer.GetCookies(uri);
            cookieManager.SetAcceptCookie(true);
            cookieManager.RemoveAllCookie();
            view.Settings.JavaScriptEnabled = true;
            Console.WriteLine("{0}", url);
            return false;
        }
    }
    

    }

    Saturday, May 27, 2017 10:17 PM

All replies