Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 未调用SFAuthenticationSession完成处理程序_Ios_Swift_Cookies_Safari_Sfauthenticationsession - Fatal编程技术网

Ios 未调用SFAuthenticationSession完成处理程序

Ios 未调用SFAuthenticationSession完成处理程序,ios,swift,cookies,safari,sfauthenticationsession,Ios,Swift,Cookies,Safari,Sfauthenticationsession,我正在尝试实现一种从Safari和App交换cookie的方法。我正在使用SFAuthenticationSession,因为cookies共享已禁用。我通读了这个主题,似乎这是实现这一目标的最佳解决方案。没有太多的博客或repo可以作为例子 我在服务器端实现了如下更改重定向 首先,我将cookie存储为https://example.com/?cookie=12345。然后,我从应用程序启动指向https://example.com/getcookie它重定向到customapp://dumm

我正在尝试实现一种从Safari和App交换cookie的方法。我正在使用
SFAuthenticationSession
,因为cookies共享已禁用。我通读了这个主题,似乎这是实现这一目标的最佳解决方案。没有太多的博客或repo可以作为例子

我在服务器端实现了如下更改重定向

首先,我将cookie存储为
https://example.com/?cookie=12345
。然后,我从应用程序启动指向
https://example.com/getcookie
它重定向到
customapp://dummy/cookies?cookie=12345

我曾经说过。swift实施如下(感谢):

您可能会注意到,我对登录不感兴趣,但之前存储了一个cookie

谁能给点建议吗?我的问题是,尽管站点正在重定向,但没有调用完成处理程序,因此我无法解析回调url

更新

我发现我在
Info.plist
中缺少协议。在向其添加自定义协议后,调用了处理程序。尽管如此,在我参与身份验证会话时,处理程序仅在第二次调用


有什么线索吗?

您好,您能分享设置SFAuthenticationSession的完整设置吗?在Info.plist中需要添加什么协议
let callbackUrl  = "customapp://dummy/cookies"
let authURL = "https://example.com/getcookie"

self.authSession = SFAuthenticationSession(url: URL(string: authURL)!, callbackURLScheme: callbackUrl, completionHandler: { (callBack:URL?, error:Error? ) in
    guard error == nil, let successURL = callBack else {
        return
    }

    let cookie = self.parseQuery(url: (successURL.absoluteString), param: "cookie")
    print(cookie!)

    })

self.authSession?.start()