I am trying to use Facebook in my iOS swift application to get some basic user information. I used Cocoapods to install the Facebook dependencies. I have updated my info.plist using the following links.
https://developers.facebook.com/docs/ios/ios9https://developers.facebook.com/quic.../?platform=ios
I receive the following compiler errors whenever I try logging in through facebook:
-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:FBSDKGraphRequestErrorC ategoryKey=0, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusC odeKey=400, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An active access token must be used to query information about the current user., com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorC ode=2500, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONR esponseKey={
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 with 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)")
}
})
}
App Delegate
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().applicat ion(application, didFinishLaunchingWithOptions: launchOptions)
}

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

func applicationDidBecomeActive(application: UIApplication) {
FBSDKAppEvents.activateApp()
}
Other Information: Swift 2, Xcode 7, iOS 9
Any suggestions would be appreciated to resolve this issue.


View Solution