gpt4 book ai didi

ios - Facebook 登录在 Swift 中崩溃

转载 作者:搜寻专家 更新时间:2023-10-31 22:48:19 24 4
gpt4 key购买 nike

单击登录按钮时出现崩溃问题。首先,我想详细介绍一下我的申请。一切都与 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)
}
//...//
}

我认为问题在于 return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) 案例。但是,我不明白为什么它会崩溃。错误如下:

Error Total Error

最佳答案

在 iOS 9.0 中,您必须将此添加到您的 plist 文件中:

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

我建议阅读有关应用程序传输安全的部分 - https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html

编辑

我还发现这个答案有很多有用的资源:NSURLSession/NSURLConnection HTTP load failed on iOS 9

关于ios - Facebook 登录在 Swift 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33456037/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com