Parse API - Facebook login not working on iPhone

When I press the login button using the Facebook button, it works on iOS simultaneously. Getting the PFUser object. Then, if I ran the same code on the iPhone device, getting the PFUser object as null. Mistake.

Code: func loginWithFacebook() { print("login with facebook") let permissions = ["public_profile"] PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions, block: { (user: PFUser?, error: NSError?) -> Void in print("################") if let error = error { print(error) } else { if let user = user { print(user) } } }) } 

IDE: xcode 7 Language: Swift2 Facebook SDK: 4.6.0 Analysis: 1.8.4 device: iPhone 5s I checked .plist has all the keys that are required. Also checked is the link identifier for typo errors. Everyone looks good. Facebook application is active.

Any help?

+1
ios iphone facebook swift
Sep 19 '15 at 16:26
source share
2 answers

In AppDelegate.swift, I have the following code:

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

According to the comments in the UIApplicationDelegate , we should use the application: openURL: options :, but it still doesn't work.

  @available(iOS, introduced=4.2, deprecated=9.0, message="Please use application:openURL:options:") optional public func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool 

Now I have changed to the following code:

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

Then he began to work normally on both the simulator and the iPhone.

+3
Sep 22 '15 at 3:17
source share

Check out this guide to resolve the problem http://discoverpioneer.com/blog/2015/09/18/updating-facebook-integration-for-ios-9/

The problem is related to application transport security. A few changes to your info.plist and everything will be installed :)

0
Sep 19 '15 at 16:34
source share



All Articles