2016-04-05 15 views
0

我有一个FBSDKLoginManagerRequestTokenHandler的问题,因为它应该被调用,但它不是。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以及与iOS 9.2.1

  • 荚的Facebook-IOS-SDK', '〜> 4.1'

阿洛斯正如我注意到我在我的日志中有这个错误:

-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" 

向plist添加数据并不如here建议的那样有帮助。我已经添加了这一点:

<key>LSApplicationQueriesSchemes</key> 
<array> 
     <string>fbapi</string> 
     <string>fb-messenger-api</string> 
     <string>fbauth2</string> 
     <string>fbshareextension</string> 
</array> 

我有这样的应用程序委托:

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

检查你有没有提到你没有设置'应用程序(应用程序:UIApplication的,的OpenURL网址:NSURL,sourceApplication:字符串?注释:AnyObject?) - > Bool' ?也是网址方案? – HardikDG

+0

@Pyro嘿,我已在一个问题中添加新评论,谢谢 –

回答

0

更好的解决方案将是您更新Facebook SDK到最新版本,但如果您指定的版本有某些特定要求,您可以检查以下内容

您在问题中提供的链接建议

如果你与iOS SDK 9.0重新编译,以下内容添加到您的应用程序的plist如果您正在使用或版本的SDK V4.5

<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应该工作,它在迅速2为我工作。2

application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { 
} 

有关整合的更多信息,你可以检查:

FB SDK doc
FB Login sample: Medium


更新:所以有可能是关于openURL的一些问题根据FB doc

,警告是可以的

This is an Xcode warning indicating the the canOpenURL: call returned false. As long as you have configured the LSApplicationQueriesSchemes entry in your plist as described above, you can ignore this warning

参考:https://developers.facebook.com/docs/ios/ios9,在底部

+0

谢谢你的回答!我仍然有一个问题,因为我提到有关canOpenURL,并没有回来后从safari打开的应用程序返回 –

+0

@MatrosovAlexander请检查您的openUrl方法与一些其他fb的例子,因为警告应该是好的根据我的更新中提到的F​​B文件回答 – HardikDG

+0

好的感谢更新,我也尝试使用pod'FBSDKLoginKit','〜> 4.10'。这个可以吗?它会抛出一个错误:'#import ' - 未找到 –