我遵循了本教程https://www.youtube.com/watch?v=cpANieebE2M,但是我使用CocoaPod来安装FBSDK,而不是下载框架并拖到我的项目中。
我使用 FBSDK版本:4.10.1
这是我的pod文件:
import UIKit
import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit
import FBSDKMessengerShareKit
class LoginViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if (FBSDKAccessToken.currentAccessToken() == nil) {
print("Not loged in..")
} else {
print("Loged in...")
}
let loginButton = FBSDKLoginButton()
loginButton.readPermissions = ["public_profile", "email", "user_friends"]
loginButton.center = self.view.center
loginButton.delegate = self
self.view.addSubview(loginButton)
}
}
extension LoginViewController: FBSDKLoginButtonDelegate {
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil {
print("login completed...")
self.performSegueWithIdentifier("goTo", sender: self)
} else {
print(error.localizedDescription)
}
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
print("User Loged out...")
}
}
这是我的LoginViewController:
InitializeComponentDirectoryInfo dir = new DirectoryInfo(".\\Notes\\");
FileInfo[] files = dir.GetFiles("*.txt");
foreach (FileInfo file in files)
{
listBox1.Items.Add(file);
}
但是当我点击登录按钮时:
它崩溃了:
答案 0 :(得分:2)
根据您的屏幕截图,您的info.plist文件中缺少fbauth2
。您需要将其添加到info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb-messenger-api20140430</string>
</array>
答案 1 :(得分:1)
正如你没有提到可可豆荚中的任何特定版本,如果你刚刚整合了可可豆荚,那么你必须只包括因为你的SDK版本高于4.6.0
如果您使用的是SDK的v4.6.0或更高版本,则只需添加:
5. Configure Xcode Project
如果你的版本仍低于4.6.0,你可以查看艾哈迈德的回答
如果在添加LSApplicationQueriesSchemas之后仍然出现错误,请检查您是否在plist中设置了facebook app id
有关这方面的更多信息,请参阅Getting Started : Facebook ios SDK
检查function transform(data) {
var o = {}, i, str;
function addPath(path) {
var parts = path.split('.'),
e = o, i = 0;
for (; i < parts.length; ++i) {
e = e[parts[i]] = e[parts[i]] || {};
}
}
function transformPathObject(dir, obj) {
var key, arr = [];
for (key in obj) {
arr.push(transformPathObject(key, obj[key]));
}
obj = {'name': dir};
if (arr.length) obj.parameters = arr;
return obj;
}
for (i = 0; i < data.length; ++i) {
str = data[i].name;
str = str.replace(/^\[(.*)\]$|(.*)/, '$1$2');
addPath(str);
}
return transformPathObject('__root__', o).parameters;
}