我已經花費了很長時間來解決這個問題,但是在登錄我的Facebook帳戶併爲我的應用程序授予使用權限之後,除了左上角的完成按鈕被擊中之外。當我點擊完成按鈕後,一切正常,但我用其他應用程序進行了測試,我不應該這樣做。我究竟做錯了什麼。我有最新的Facebook sdk 4.6我相信,我認爲我的.plist是正確的,並且我已經添加了所有框架。必須在ios 9上登錄到Facebook後點擊「完成」按鈕
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb497638107079749</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>NUMBER</string>
<key>FacebookDisplayName</key>
<string>What's Up</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
<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>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
</dict>
功能登錄按鈕不運行,直到我打的完成按鈕
import UIKit
import FBSDKLoginKit
class ViewController: UIViewController, FBSDKLoginButtonDelegate {
//@IBOutlet weak var loginButton: FBSDKLoginButton!
@IBOutlet weak var loginButton: FBSDKLoginButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if(FBSDKAccessToken.currentAccessToken() == nil){
print("user is not logged in")
}else{
print("user is logged in")
}
loginButton.delegate = self
loginButton.readPermissions = ["public_profile","email","user_friends"]
print("this is all good")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
print("clicked")
if (error == nil){
print("Login Complete")
print("i am in the if")
self.performSegueWithIdentifier("showNew", sender: self)
}else{
print(error.localizedDescription)
}
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
print("user logged out")
}
一旦重置模擬器,然後重試。 –
我添加了代碼,但我檢查了一個教程,這正是另一個人對ios 8所做的,但是我找不到ios 9的教程,而且我很困擾objective-c,所以文檔沒有多大幫助。 – user2581628
http://stackoverflow.com/questions/28248182/ios-swift-and-facebook-sdk檢查此鏈接。 –