gpt4 book ai didi

ios - FBSession.openActiveSessionWithReadPermissions 不调用 completionHandler

转载 作者:搜寻专家 更新时间:2023-10-31 21:52:46 28 4
gpt4 key购买 nike

我正在使用 Facebook SDK 实现 OAuth 登录,但是 FBSession.openActiveSessionWithReadPermissions:allowLoginUI:completionHandler 方法既没有调用 completionHandler 也没有返回“true”,这表明缓存 token 。除了这个,其他一切似乎都工作正常。这段代码有什么问题?

    var completionHandler: FBSessionStateHandler = {

session, status, error in

NSLog("token not cached");

if error {

// Login failed for some reason, so we notify the delegate.
self.delegate.didFailOpenningSession?(self, withError: ErrorUtility.error(
code: .FailedOpenningSession,
withFacebookError: error
));

// Don't proceed on errors
return;
}

// Session is now open, we should notify the delegate
self.delegate.didOpenSession?(self);
};

NSLog("here");

// Open the session, prompting the user if necessary. This might send the application to the background
if FBSession.openActiveSessionWithReadPermissions(["public_profile"], allowLoginUI: true, completionHandler: completionHandler) {

NSLog("Token cached");

// If we end up here, the session token must exist, so we now have an open session
self.delegate.didOpenSession?(self);
}

编辑:我忘了提到 NSLog 记录“这里”,而不是“ token 缓存”或“ token 未缓存”

编辑:现在事情变得有点奇怪了。当我的应用程序启动时,我会显示一个带有 Facebook 登录按钮的屏幕。当用户按下按钮时,上面的代码将被触发。在我授权该应用程序后,该应用程序返回到同一屏幕(它不应该,但在调用完成处理程序之前我不能以任何其他方式执行此操作)。然后我尝试再次按下按钮,现在我确实得到了日志。

这是我得到的:

    here
token not cached
here

第一行来自第一次按下按钮,另外两行是在我第二次按下时出现的。现在有什么奇怪的呢? “ token 未缓存”和“此处”不应该颠倒过来吗???是调用上次调用的 compettionHandler 还是什么?

没关系,那么多是固定的。

编辑:另一件事。如果我多次按下按钮,我总是得到“ token 未缓存”。我觉得应该是缓存

最佳答案

解决了。我错过了方法 AppDelegate.application:handleOpenURL -> Bool

关于ios - FBSession.openActiveSessionWithReadPermissions 不调用 completionHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24601066/

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