2016-04-05 16 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 ' - 未找到 –