OGeek|极客世界-中国程序员成长平台

标题: ios - NSHTTPCookieStorage 跨多个应用共享 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 09:57
标题: ios - NSHTTPCookieStorage 跨多个应用共享

如何在多个 iOS 应用程序之间共享 NSHTTPCookieStorage?我希望 MYAPP A 和 MYAPP B 使用相同的 cookie,这样我就可以轻松地在它们之间切换。

我在 NSHTTPCookieStorage.h 中找到了以下方法,但在 documentation 中没有看到它.

+ (NSHTTPCookieStorage *)sharedCookieStorageForGroupContainerIdentifierNSString *)identifier NS_AVAILABLE(10_11, 9_0);



Best Answer-推荐答案


为将来可能遇到此问题的其他 6 个人回答我自己的问题...

在我的研究中,我发现 sharedCookieStorageForGroupContainerIdentifier: 是专为 NSURLSession 设计的新功能,它允许您直接指定 sharedHTTPCookieStorage 以外的 cookie 存储。

不幸的是,此功能不向后兼容 NSURLConnection 功能套件,如 NSURLConnection automatically persists its cookies to sharedHTTPCookieStorage ,并且此行为不能被覆盖。

TL;DR:如果您想要自己的 Cookie 存储,请使用 NSURLSession。

关于ios - NSHTTPCookieStorage 跨多个应用共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34143129/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4