0

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.. I need someone who knows C#, and Xamarin.Android. Thanks!

    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;
        }
    }
}
Doubt
  • 3
  • 7
  • Did you see this: https://stackoverflow.com/questions/12648099/making-facebook-login-work-with-an-android-webview/19068076#19068076 – pinedax May 24 '17 at 04:36
  • I saw that but I'm new at programming so i didn't understand much of that code :) – Doubt May 26 '17 at 15:43

0 Answers0