react-native-fbsdk不支持redirect_uri URL

时间:2018-09-30 19:13:28

标签: react-native react-native-ios react-native-fbsdk

我正在尝试使用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={...

错误: 线程1:信号SIGABRT

如何摆脱redirect_uri错误?

1 个答案:

答案 0 :(得分:0)

我的FacebookAppId的{​​{1}}文件中的CFBundleURLSchemesinfo.plist错误。我必须去https://developers.facebook.com/apps/29476792337468632/fb-login/quickstart/?sdk=fbsdk来查看APP ID是什么(它显示在您的App名称旁边的导航栏中)。快速入门实际上将为您提供下面的整个代码块以及正确的应用程序ID,以粘贴到info.plist中。

ios/appName/info.plist