OGeek|极客世界-中国程序员成长平台

标题: ios swift facebook登录 fb_mobile_login_native_app_switch_dialog_result 错误 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:21
标题: ios swift facebook登录 fb_mobile_login_native_app_switch_dialog_result 错误

我正在使用 facebook swift sdk。

当我点击登录按钮时,我收到此警告/错误:

FBSDKLog: Invalid identifier: 'fb_mobile_login_native_app_switch_dialog_result'. Must be between 1 and 40 characters, and must be contain only alphanumerics, _, - or spaces, starting with alphanumeric or _.

我的代码:

@IBAction func fbLoginBtnDidTouch(_ sender: AnyObject) {
        let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
        fbLoginManager.logIn(withReadPermissions: ["email"], from: self) { (result, error) -> Void in
            if (error == nil){

                let fbloginresult : FBSDKLoginManagerLoginResult = result!

                if (result?.isCancelled)! {
                    return
                }

                if(fbloginresult.grantedPermissions.contains("email"))
                {
                    self.getFBUserData()
                }
            }
        }
    }
    func getFBUserData(){
        if((FBSDKAccessToken.current()) != nil){
            FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, email"]).start(completionHandler: { (connection, result, error) -> Void in
                if (error == nil){
                    let fbJson = JSON(result ?? [])
                    if let fbId = fbJson["id"].string, let fbEmail = fbJson["email"].string {

                        self.fetchedFbId = fbId
                        self.fetchedFbEmail = fbEmail

                        var fbLoginParams = [String: Any]()

                        fbLoginParams["facebook_id"] = fbId

                        self.createFbAccount(fbLoginParams)
                    }
                }
            })
        }
    }



Best Answer-推荐答案


进入您需要添加的应用目标下的 info.plist 文件:

FacebookAppID

<key>FacebookAppID</key>
<string>123456789012345</string>

CFBundleURLTypes

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb123456789012345</string>
        </array>
    </dict>
</array>

LSApplicationQueriesSchemes:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
</array> 

从 Facebook 开发者门户检索到的 Facebook 应用 ID。

关于ios swift facebook登录 fb_mobile_login_native_app_switch_dialog_result 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41233562/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) Powered by Discuz! X3.4