3

I have a crash problem by clicking the login button. First, I want to give the details of my application. Everything is the same as the tutorial in Facebook.

Files Image

ViewController.swift

import UIKit
import Parse
import FBSDKCoreKit
import FBSDKLoginKit

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    let testObject = PFObject(className: "TestObject")
    testObject["foo"] = "bar"
    testObject.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
        print("Object has been saved.")
    }
    let loginButton: FBSDKLoginButton = FBSDKLoginButton()
    loginButton.center = self.view.center
    self.view.addSubview(loginButton)
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
}

AppDelegate.swift

import UIKit
import Parse
import Bolts
import FBSDKCoreKit
import FBSDKLoginKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    Parse.enableLocalDatastore()
    Parse.setApplicationId("----", clientKey: "----")
    PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
    return true
}


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

I think the problem is about return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) case. However, I can not understand why does it crash. The error is below:

Error Total Error

Onur Tuna
  • 1,030
  • 1
  • 10
  • 28

1 Answers1

2

In iOS 9.0 you have to add this to your plist file:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

I recommend reading section about App Transport Security - https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html

Edit

Also I found this answer with a lot of useful resources: NSURLSession/NSURLConnection HTTP load failed on iOS 9

Community
  • 1
  • 1
Superian007
  • 395
  • 7
  • 25