I configure in my app authentication with Facebook Login in Swift 2.
Everything works perfectly on IOS Simulator (IOS 8 and 9): User click on "Login with Facebook", then a safari page opening, then authentication continue and finally user is logged correctly:
But when I try on my Ipod Touch , it ALWAYS block and fail on this message ( Sorry, something went wrong. We're working on it and we'll get it fixed as soon as we can ), and my user is not logged:
I have tried a lot of things :
But still not working.. Any help would be appreciated!
Here is my code:
AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//For Facebook Login
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)
}
ViewController.swift
class ViewController: UIViewController, FBSDKLoginButtonDelegate {
@IBOutlet weak var signInButtonFB: FBSDKLoginButton!
override func viewDidLoad() {
super.viewDidLoad()
//Configure Facebook
signInButtonFB.readPermissions = ["public_profile", "email", "user_friends"]
signInButtonFB.delegate = self
//Configure Facebook SignIn
if (FBSDKAccessToken.currentAccessToken() != nil)
{
print("Logged in !")
}
else
{
print("not logged")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//MARK: Facebook
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
print("Début login Button")
if ((error) == nil)
{
print("Login Complete")
returnUserData()
}
else {
print ("Voici l'erreur:"+error.localizedDescription)
}
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
print("User Logged Out")
}
Looks like my app Facebook was still in development mode.. I forget to set "Contact Name" and allow my app to public access.
SETUP FOR FACEBOOK APP:
My Apps -> Settings -> Basic -> Contact Email = Give email valid
My Apps -> Status and Review Tab -> "Do you want to make this app and all its live features available to the general public?" = Yes
I meet the same problem. I fixed by checking the login permissions. Also check again the spelling mistakes of the permission texts. Make sure your permissions are all enabled on developer.facebook.com.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.