菜鸟教程小白 发表于 2022-12-11 18:21:17

ios swift facebook登录 fb_mobile_login_native_app_switch_dialog_result 错误


                                            <p><p>我正在使用 facebook swift sdk。</p>

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

<pre><code>FBSDKLog: Invalid identifier: &#39;fb_mobile_login_native_app_switch_dialog_result&#39;. Must be between 1 and 40 characters, and must be contain only alphanumerics, _, - or spaces, starting with alphanumeric or _.
</code></pre>

<p>我的代码:</p>

<pre><code>@IBAction func fbLoginBtnDidTouch(_ sender: AnyObject) {
      let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
      fbLoginManager.logIn(withReadPermissions: [&#34;email&#34;], from: self) { (result, error) -&gt; Void in
            if (error == nil){

                let fbloginresult : FBSDKLoginManagerLoginResult = result!

                if (result?.isCancelled)! {
                  return
                }

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

                        self.fetchedFbId = fbId
                        self.fetchedFbEmail = fbEmail

                        var fbLoginParams = ()

                        fbLoginParams[&#34;facebook_id&#34;] = fbId

                        self.createFbAccount(fbLoginParams)
                  }
                }
            })
      }
    }
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>进入您需要添加的应用目标下的 info.plist 文件:</p>

<p><strong>FacebookAppID</strong></p>

<pre><code>&lt;key&gt;FacebookAppID&lt;/key&gt;
&lt;string&gt;123456789012345&lt;/string&gt;
</code></pre>

<p><strong>CFBundleURLTypes</strong></p>

<pre><code>&lt;key&gt;CFBundleURLTypes&lt;/key&gt;
&lt;array&gt;
    &lt;dict&gt;
      &lt;key&gt;CFBundleURLSchemes&lt;/key&gt;
      &lt;array&gt;
            &lt;string&gt;fb123456789012345&lt;/string&gt;
      &lt;/array&gt;
    &lt;/dict&gt;
&lt;/array&gt;
</code></pre>

<p><strong>LSApplicationQueriesSchemes:</strong></p>

<pre><code>&lt;key&gt;LSApplicationQueriesSchemes&lt;/key&gt;
&lt;array&gt;
    &lt;string&gt;fbapi&lt;/string&gt;
    &lt;string&gt;fb-messenger-api&lt;/string&gt;
    &lt;string&gt;fbauth2&lt;/string&gt;
    &lt;string&gt;fbshareextension&lt;/string&gt;
&lt;/array&gt;
</code></pre>

<p>从 Facebook 开发者门户检索到的 Facebook 应用 ID。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios swift facebook登录 fb_mobile_login_native_app_switch_dialog_result 错误,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/41233562/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/41233562/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios swift facebook登录 fb_mobile_login_native_app_switch_dialog_result 错误