我遇到了FBSDKLoginManagerRequestTokenHandler的问题,因为它应该被调用,但事实并非如此。
let login = FBSDKLoginManager()
login.logInWithReadPermissions(["email"]) { (result, error) in
// should be retuned here after dismissing Safari, as I understood, but app never call this block.
}
它在第一步完美,所以应用程序打开safari,我能够登录Facebook。
它说“应用程序已经被授权”,我点击了Safari上的“确定”按钮,然后我看到一条提示“在我的应用程序中打开此页面”,我点击打开,没有任何反应。我的意思是回复没有回电。
详细信息:
iPhone 6 plus iOS 9.2.1
pod'Facebook-iOS-SDK','〜> 4.1'
Alos,因为我注意到我的日志中有这个错误:
-canOpenURL: failed for URL: "fbauth://authorize/?client_id=1150389881653102&default_audience=friends&display=touch&e2e=%7B%22init%22%3A1459873693399%7D&legacy_override=v2.3&redirect_uri=fbconnect%3A%2F%2Fsuccess&response_type=token%2Csigned_request&return_scopes=true&scope=email&sdk=ios&sdk_version=4.1.0&state=%7B%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A0%2C%220_auth_logger_id%22%3A%228FB19521-A8ED-49DA-A7DC-E5382029252C%22%7D" - error: "This app is not allowed to query for scheme fbauth"
根据建议here向plist添加数据没有帮助。我添加了这个:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
我在app delegate中有这个:
public func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
{
return self.applicationManager.application?(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) ?? false
}
但是在iOS 9中看到它已被弃用
答案 0 :(得分:0)
更好的解决方案是将您的Facebook SDK更新到最新版本,但如果您指定的版本有特定要求,可以查看以下内容
您在问题中提供的链接建议
如果您使用iOS SDK 9.0进行重新编译,如果您使用的是SDK版本 v4.5或更早版,请将以下内容添加到应用程序的plist中:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb-messenger-api20140430</string>
</array>
正如您所提到的,您使用的是 4.1 版本,如果您使用的是版本4.10,则您的plist应该按照您提到的那样工作
对于你可以实现这个的方法,它在swift 2.2中适用于我
application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
}
有关集成的更多信息,您可以查看:
FB SDK doc
FB Login sample: Medium
更新:因此openURL
可能存在一些问题,因为根据FB文档警告是可以的
这是一个Xcode警告,指示返回的canOpenURL:调用 假。只要您配置了LSApplicationQueriesSchemes 如上所述在你的plist中输入,你可以忽略这个警告