我有一個用於驗證用戶的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