代码之家  ›  专栏  ›  技术社区  ›  BeniaminoBaggins

react native fbsdk不支持重定向\u uri URL

  •  0
  • BeniaminoBaggins  · 技术社区  · 6 年前

    我正在尝试使用react native fbsdk允许用户登录到我的应用程序。我设置了一个登录按钮。

    代码:

    import React, { Component } from 'react'
    import { View } from 'react-native'
    import { LoginButton, AccessToken } from 'react-native-fbsdk'
    
    export default class FBLoginButton extends Component {
      render() {
        return (
          <View>
            <LoginButton
              onLoginFinished={
                (error, result) => {
                  if (error) {
                    alert('Login failed with error: ' + error.message)
                  } else if (result.isCancelled) {
                    alert('Login was cancelled')
                  } else {
                    AccessToken.getCurrentAccessToken().then(
                        (data) => {
                          console.log(data.accessToken.toString())
                        }
                      )
                  }
                }
              }
              onLogoutFinished={() => alert('User logged out')}/>
          </View>
        )
      }
    }
    

    当我点击登录按钮,我得到这个在模拟器上出现

    enter image description here

    如果我尝试添加权限,则会出现xcode错误:

    <LoginButton
              publishPermissions={['email']}
              onLoginFinished={...
    

    错误:

    如何消除重定向\u uri错误?

    1 回复  |  直到 6 年前
        1
  •  0
  •   BeniaminoBaggins    6 年前

    我错了 FacebookAppId CFBundleURLSchemes info.plist 我的文件 ios/appName/info.plist . 我不得不去 https://developers.facebook.com/apps/29476792337468632/fb-login/quickstart/?sdk=fbsdk 查看应用程序ID是什么(它显示在你的应用程序名称旁边的导航栏中)。“快速入门”实际上会为您提供下面的整个代码块以及要粘贴到其中的正确应用程序id信息列表.

    <key>CFBundleURLTypes</key>
    <array>
      <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>fb29476792337468632</string>
      </array>
      </dict>
    </array>
    <key>FacebookAppID</key>
    <string>29476792337468632</string>
    <key>FacebookDisplayName</key>
    <string>My App Name</string>