我有一个用于验证用户的UIWebView。用户通过验证后,我保存和删除cookies像这样: -Cookie未加载UIWebView iOS
public static void SaveCookies()
{
NSHttpCookieStorage cookieStorage = NSHttpCookieStorage.SharedStorage;
foreach (var nscookie in cookieStorage.Cookies)
{
cookieStorage.SetCookie(nscookie);
}
}
public static void DeleteCookies()
{
NSHttpCookieStorage cookieStorage = NSHttpCookieStorage.SharedStorage;
foreach (var nscookie in cookieStorage.Cookies)
{
cookieStorage.DeleteCookie(nscookie);
}
}
我此行我的AppDelegate
public override void OnActivated (UIApplication application)
{
// Restart any tasks that were paused (or not yet started) while the application was inactive.
// If the application was previously in the background, optionally refresh the user interface.
NSHttpCookieStorage.SharedStorage.AcceptPolicy = NSHttpCookieAcceptPolicy.Always;
}
我打电话SaveCookies像这样:
var authResponse = REsponse after authentication
if (authResponse != null)
{
//SAve cookies here
AppDelegate.SaveCookies();
...
}
但Iam不确定如何在下次应用程序启动时将Cookie加载并传递到webview,以便用户不会再次显示登录页面。现在,每次启动应用程序时都会显示登录页面。我想启用一次性登录。我怎样才能做到这一点?
对此有任何好运..? – Ameer