ios - Xamarin.iOS 等效于 Xamarin.Android 的 CookieManager.Instance
问题描述
我正在我的 Xamarin Forms 应用程序中使用 Cookie。
在某些时候,我需要将存储的 Cookie 作为字符串获取。
在 Android 中,我可以将CookieManager.Instance.GetCookie(url);
其解析为返回所有 Cookie 的字符串,用 ; 分隔。
我正在寻找 Xamarin.iOS 的等价物,因为我正在开发跨平台应用程序。
期待您的回答。
解决方案
在 iOS 中,如果您使用 NSUrlSession,您的 cookie 会自动与 UIWebView/WKWebView 和 NSUrlSession 共享。
要访问 Cookie 容器,您只需要使用DependencyService或Custom Renderer进行调用。
NSHttpCookieStorage shareStore = NSHttpCookieStorage.SharedStorage;
var cookies = shareStore.CookiesForUrl(url);
推荐阅读
- r - 匹配两个 data.frame(每个列名一个)并创建一个新的 data.frame
- amazon-web-services - AWS 是否对 RDS 实例启动时间收费?
- laravel - Fatal:Class Illuminate\Routing\RouteCollection 包含 1 个抽象方法,因此必须声明为抽象方法或实现其余方法
- tensorflow - categorical_crossentropy 实现的解释
- php - 为什么显示的是会话数组而不是 ID?
- python-3.x - 嵌入式 python 挂在导入站点包上
- bash - 表达式 .[].[] 的 Bash 评估
- c - 我无法理解这个聊天程序的结果
- php - comment_reply_link 带有 svg 图标而不是 reply_text
- html - CSS中的Z-Index没有任何效果