我正在制作工作网站的webview,但在webview中,facebook登录不起作用。我输入电子邮件,通过,当我点击登录时,它会重新登录登录页面。我需要有人知道C#和Xamarin.Android。谢谢!
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;
}
}
}