gpt4 book ai didi

ios - 与 Safari 同步 - SFSafariViewController 的扩展

转载 作者:搜寻专家 更新时间:2023-11-01 06:32:11 31 4
gpt4 key购买 nike

我知道 SFSafariViewController 有私有(private) cookie 存储和其他实现。但是,我知道我们可能会为每个(每个 native 系统)Swift 类编写一个扩展。我需要与 native Safari 共享 cookie,或者使用一些 header 请求从我的应用程序打开 Safari。至少,如何创建用于获取/设置 cookie 的 API

最佳答案

  1. SFSafariVC 和 native Safari 之间的 Cookie 共享已在 iOS >= 11 中被禁用。

At WWDC, Apple announced a change in the behavior of Safari View Controller with iOS 11 in that stored data (cookies, local storage, etc.) will no longer be shared between instances of Safari View Controller. We've confirmed this in-house with a beta version, and this seems to be independently confirmed by the folks at Branch.

From AppAuth-iOS' repo: user whitehatguy

  1. SFSafariVC 的唯一 API 是为给定的 URL 创建一个新实例。您不能设置或修改 cookie。

如果您需要执行自定义代码,请查看 WKWebView (iOS >= 8)/UIWebView (iOS < 8)。有用的答案:Getting cookies in WKWebView

SFAuthenticationSession创建是为了允许 SSO/OAuth 身份验证流程,它与 native Safari 共享 cookie,但开发人员无法直接访问。

A class that manages sharing a one-time web service login, along with cookies and website data, between Safari and an app, which can also be used for automatic login for other associated apps.

The two cases where you would use SFAuthenticationSession are:

  • Logging in to a third party's service using an authentication protocol (e.g. OAuth). This option works well for social network applications.
  • Providing a single sign-on (SSO) experience for applications. This option works well for enterprise companies that have many applications installed on the same device.

SFAuthenticationSession's documentation by Apple

关于ios - 与 Safari 同步 - SFSafariViewController 的扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45653024/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com