- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用 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/
我最近开始使用 Facebook SDK 3.1,在使用 openActiveSessionWithReadPermissions 登录时遇到了一些问题。 实际上,登录工作完美,如果有可用的缓存 to
我有一个 iOS 应用程序,它已经使用 Facebook API 正常运行了大约一年。 最近我更新到最新版本的 Facebook API。 我注意到的是,当我现在调用 openActiveSessio
我正在使用 Facebook SDK 实现 OAuth 登录,但是 FBSession.openActiveSessionWithReadPermissions:allowLoginUI:comple
我们正在编写一个与 Facebook 集成的原生 iOS 应用程序。几个月前,我们通过 developers.facebook.com 设置了一个占位符 FB 应用程序,并通过它进行了所有测试。现在我
我正在尝试将适用于 iOS 的 facebook sdk 从 3.0 升级到 3.1.1。我已经添加了新的 FacebookSDK。我想我做对了,很简单...安装下载的 FacebookSDK-3.1
我之前使用的是适用于 iOS 的 Facebook SDK 3.x。我的代码在多个地方都有 FBSession openActiveSessionWithReadPermissions,现在我使用的是
背景 最近升级到 Facebook SDK 3.2 在设备和模拟器上测试(iOS 5.1 到 6.1) 错误仅在尝试对 Facebook 测试用户 进行身份验证时出现。 错误 The Facebook
我需要知道用户在 openActiveSessionWithReadPermissions 执行期间何时未授予 Facebook 访问我的应用程序的权限。 (未授予意味着在“设置”->“Faceboo
我有一个分享链接的按钮。我基本上使用两个电话:openActiveSessionWithReadPermissions 和 requestNewPublishPermissions。 所以这是按钮操作
我从 facebook 教程中得到这段代码: - (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI { NSArray *permissions
在任何事情之前,我都阅读了 this和 this在提问之前解决下面的问题。 我的问题是,当 accessToken 过期时(无论是因为过期日期,还是通过从我的 Facebook 的应用程序中心删除应用
我是一名优秀的程序员,十分优秀!