gpt4 book ai didi

ios - 与 FacebookSDK 集成时获取个人资料信息

转载 作者:行者123 更新时间:2023-11-28 15:52:34 25 4
gpt4 key购买 nike

我一直在将 FacebookSDK 与堆栈溢出和一些教程集成在一起,但它对我来说工作不正常。我无法获取配置文件数据。这个方法甚至没有被调用。只出现“完成登录”。登录过程正在运行,但注销选项从未按应有的方式出现在按钮上。感谢您提供任何提示。

 import Foundation
import UIKit
import FBSDKLoginKit
import FBSDKCoreKit



class mainView: UIViewController, FBSDKLoginButtonDelegate {

@IBOutlet weak var navigationBar: UINavigationBar!
@IBOutlet weak var mainImage: UIImageView!
@IBOutlet weak var getRecipeBtn: UIButton!
@IBOutlet weak var addImageBtn: UIButton!

let loginButton: FBSDKLoginButton = {
let button = FBSDKLoginButton()
button.readPermissions = ["email"]
return button
}()

override func viewDidLoad() {
super.viewDidLoad()

view.addSubview(loginButton)
loginButton.center = view.center
loginButton.delegate = self

if let token = FBSDKAccessToken.current() {
fetchProfile()
}
}

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
print("completed login")
}

func loginButtonWillLogin(_ loginButton: FBSDKLoginButton!) -> Bool {
return true
}

func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {

}


func fetchProfile() {
print("fetch profile")

FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "email, first_name, last_name, id"]).start(completionHandler: { (connection, result, error) in guard

let result = result as? NSDictionary,
let email = result["email"] as? String,
let user_name = result["fist_name"] as? String,
let user_id = result["id"] as? String

else {
return
}
print(email)


})
}
}

这是我的控制台日志部分:(我已将 fbauth 添加到 info.plist。)

RecipeMaster[19428:630625] -canOpenURL:URL 失败:“fbauth2:/”- 错误:“操作无法完成。(OSStatus 错误 -10814。)” 完成登录

2017-02-08 22:48:23.308043 RecipeMaster[19428:640928] PAC 提取失败,出现错误 [NSURLErrorDomain:-1003]

2017-02-08 22:48:23.308482 RecipeMaster[19428:641029] [] nw_proxy_resolver_create_parsed_array PAC 评估错误:NSURLErrorDomain: -1003

最佳答案

您可能必须转到 Targets->Capabilities 并启用钥匙串(keychain)共享(它可以为您的应用程序访问钥匙串(keychain)),according to this answer.

关于ios - 与 FacebookSDK 集成时获取个人资料信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42124361/

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