In my app i integrated facebook login , and put all the settings required. But when i was trying to login , i get this error
-canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
But i have put the
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
in the .plist file , is there anyway that i can find the issue ??
edited
self.loginButton.delegate = self;
if (FBSDKAccessToken.currentAccessToken() != nil)
{
// User is already logged in, do work such as go to next view controller.
}
else
{
loginButton.center = self.view.center
loginButton.readPermissions = ["public_profile", "email", "user_friends"]
loginButton.delegate = self
}
//MARK : facebook integration
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
print(result);
if ((error) != nil)
{
// Process error
self.showCancelAlert("Error", message: "Error occured")
}
else if result.isCancelled {
// Handle cancellations
}
else {
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if result.grantedPermissions.contains("email")
{
// Do work
self.returnUserData();
}else{
self.showCancelAlert("Error", message: "Cannot process with your email address")
}
}
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
}
// accessToken is your Facebook id
func returnUserProfileImage(accessToken: NSString) -> String
{
let userID = accessToken as NSString
let facebookProfileUrl = NSURL(string: "http://graph.facebook.com/\(userID)/picture?type=large")
if facebookProfileUrl?.absoluteString != nil{
return (facebookProfileUrl?.absoluteString)!;
}else{
return "";
}
}
func returnUserData()
{
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: nil)
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
if ((error) != nil)
{
// Process error
print("error \(error)")
}
else
{
let userName : NSString = result.valueForKey("name") as! NSString
UserDefaults.sharedInstace.setUsername(userName as String)
if result.valueForKey("email") != nil{
let userEmail : NSString = result.valueForKey("email") as! NSString
if let id: NSString = result.valueForKey("id") as? NSString {
print("ID is: \(id)")
self.showLoading("Signin...")
WebClient.sharedInstace.socialLogin(SocialLogin(uid:String(id) , name: userName as String, imageUrl: self.returnUserProfileImage(id), email: userEmail as String, provider: "facebook"))
} else {
print("ID es null")
self.showCancelAlert("Error", message: "Cannot process with your email address")
self.loginButtonDidLogOut(self.loginButton)
}
}else{
FBSDKLoginManager().logOut()
self.loginButtonDidLogOut(self.loginButton)
print("email es null")
self.showCancelAlert("Error", message: "Cannot process with your email address")
}
}
})
}