gpt4 book ai didi

ios - 苹果评论中应用程序在 Facebook 上崩溃

转载 作者:行者123 更新时间:2023-11-29 05:47:06 25 4
gpt4 key购买 nike

我们无法审核您的应用,因为它在启动时崩溃了。我们附上了详细的崩溃日志来帮助解决此问题。

具体来说,用户使用 Facebook 登录后,您的应用在启动时仍然崩溃。

我无法捕获崩溃或任何错误。这是我认为崩溃的地方的代码(在用户使用 Facebook 登录后立即运行)

@IBAction func Btn_facebook(_ sender: Any)
{
getFacebookUserInfo()
}

func getFacebookUserInfo()
{
let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()

fbLoginManager.logIn(withReadPermissions: ["public_profile","email"], from: self) { (result, error) -> Void in
if (error == nil)
{
let fbloginresult : FBSDKLoginManagerLoginResult = result!
// if user cancel the login
if (result?.isCancelled)!{
return
}
if(fbloginresult.grantedPermissions.contains("email"))
{
self.getFBUserData()
self.fbtoken = result!.token.tokenString

}
}
}
}

func getFBUserData()
{
if((FBSDKAccessToken.current()) != nil)
{
FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, email, picture"]).start(completionHandler: { (connection, result, error) -> Void in

if result != nil {

guard FBSDKAccessToken.current().tokenString != nil else {
debugPrint("failed to get access token")
return
}

guard let result = result as? NSDictionary, let user_id_fb = result["id"] as? String else {
print("error")

return
}

}

if (error == nil)
{

let fbDetails = result as! NSDictionary

let field = result! as? [String:Any]
if let imageURL = ((field!["picture"] as? [String: Any])?["data"] as? [String: Any])?["url"] as? String {
print(imageURL)
let url = URL(string: imageURL)
print(url!)
self.fburl = imageURL
print(self.fburl!)

}
let checkemail = fbDetails["email"] as? String

if(checkemail != nil)
{
print(" check email not nil ", checkemail as Any)

self.fbemail = (fbDetails["email"] as? String)
self.fbid = (fbDetails["id"] as? String)
self.fbname = (fbDetails["name"] as? String)

self.GandfLogin(name: self.fbname!, email: self.fbemail!, post_image: (self.fburl!))
}
else
{
print(" check email nil ",checkemail ?? String.self)

self.fbid = (fbDetails["id"] as? String)
self.fbname = (fbDetails["name"] as? String)

self.GandfLogin(name: self.fbname!, email: self.fbid!, post_image: (self.fburl!))
}

}
else
{
print(error?.localizedDescription ?? "Not found")
}
})




}
}

最佳答案

使用软展开代替!在多数情况下因为如果 Facebook 不发送您要找回的数据,可能会导致崩溃

这样做:

guard let fbDetails = result as NSDictionary else {
//Show error to user or something else
return
}

关于ios - 苹果评论中应用程序在 Facebook 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56035828/

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