iOS SDK访问令牌问题

我想在我的iOS快速应用程序中使用Facebook来获得一些基本的用户信息。 我用Cocoapods来安装Facebook依赖项。 我已经使用以下链接更新了我的info.plist。

https://developers.facebook.com/docs/ios/ios9 https://developers.facebook.com/quickstarts/115956755431487/?platform=ios

每当我尝试通过Facebooklogin时收到以下编译器错误:

-canOpenURL: failed for URL: "fbauth2:/" - error: "(null)" -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)" Error: Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=400, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An active access token must be used to query information about the current user., com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=2500, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={ body = { error = { code = 2500; "fbtrace_id" = F1CmQQhd4pA; message = "An active access token must be used to query information about the current user."; type = OAuthException; }; }; code = 400; }} 

Podfile

 source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' use_frameworks! pod 'FBSDKCoreKit', '~> 4.8' pod 'FBSDKLoginKit', '~> 4.8' pod 'FBSDKShareKit', '~> 4.8' 

ViewController与FBSDKLoginButtonDelegate

 override func viewDidLoad() { super.viewDidLoad() var loginButton = FBSDKLoginButton() loginButton.readPermissions = ["user_about_me", "email", "public_profile"] loginButton.center = self.view.center loginButton.delegate = self self.view.addSubview(loginButton) } func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) { let fields = "email, name, first_name, last_name" let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields" : fields]) graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in if ((error) != nil) { print("Error: \(error)") } }) } 

应用程序委托

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) } func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) } func applicationDidBecomeActive(application: UIApplication) { FBSDKAppEvents.activateApp() } 

其他信息:Swift 2,Xcode 7,iOS 9

任何build议,将不胜感激解决这个问题。

我的错误是我的AppDelegate中有以下两个函数。 使用sourceApplication的openURL方法已被弃用,因此应用程序将使用更新的方法。 但是,Facebook自己的文档声明使用不合适的版本,导致我的错误位于: https : //developers.facebook.com/docs/ios/getting-started

 func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) } func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { } 

Facebook表示使用弃用的openURL http://imgur.com/kwI5VId