首页指南参考教程

使用 Facebook 身份验证

有关使用 React-native-fbsdk-next 库将 Facebook 身份验证集成到 Expo 项目中的指南。


react-native-fbsdk-next 库提供了 Facebook 的 Android 和 iOS SDK 的封装器。它允许将 Facebook 身份验证集成到你的 Expo 项目中,并提供对原生组件的访问。

¥The react-native-fbsdk-next library provides a wrapper around Facebook's Android and iOS SDKs. It allows integrating Facebook authentication into your Expo project and provide access to native components.

本指南提供了有关使用 Expo for Android 配置库的更多信息。

¥This guide provides additional information on configuring the library with Expo for Android.

先决条件

¥Prerequisites

react-native-fbsdk-next 库无法在 Expo Go 应用中使用,因为它需要自定义原生代码。了解有关 将自定义原生代码添加到你的应用 的更多信息。

¥The react-native-fbsdk-next library can't be used in the Expo Go app because it requires custom native code. Learn more about adding custom native code to your app.

安装

¥Installation

有关如何安装和配置库的说明,请参阅 react-native-fbsdk-next 文档:

¥See react-native-fbsdk-next documentation for instructions on how to install and configure the library:

React Native FBSDK 下一篇:Expo 安装说明

安卓配置

¥Configuration for Android

将 Android 添加为 Facebook 项目中的平台需要你的应用获得 Google Play 商店的批准,以便它具有有效的 Play 商店 URL 以及与你的应用关联的 package 名称。否则,你将遇到以下错误:

¥Adding Android as a platform in your Facebook project requires you to have your app approved by Google Play Store so that it has a valid Play Store URL, and the package name associated with your app. Otherwise, you'll run into the following error:

有关如何为应用商店构建项目的更多信息,请参阅以下指南:

¥See the following guides for more information on how to build your project for app stores:

为应用商店构建你的项目

首次手动上传 Android 应用

将应用上传到 Play 商店后,你就可以提交应用评论。一旦获得批准,Facebook 项目将能够通过 Play 商店 URL 访问它。

¥Once you have uploaded the app to the Play Store you can submit your app review. When it is approved the Facebook project will be able to access it at a Play Store URL.

之后,转到 Facebook 项目的“设置”>“基本”并添加 Android 平台。你需要提供密钥哈希、包名称和类名称。

¥After that, go to your Facebook project's Settings > Basic and add the Android platform. You'll need to provide the Key hash, Package name and Class name.

  • 要添加密钥哈希,请转至 Play 商店控制台,从“发布”>“设置”>“应用完整性”>“应用签名密钥证书”获取 SHA-1 证书指纹。然后,将证书的 Hex 值转换为 Base64 并将其添加到 Facebook 项目中的 Android > Key hashes 下。

    ¥To add Key hash, go to your Play Store Console to obtain the SHA-1 certificate fingerprint from Release > Setup > App Integrity > App signing key certificate. Then, convert the value of the Hex value of the certificate to Base64 and add it under the Android > Key hashes in your Facebook project.

  • 你可以在 应用配置android.package 字段下找到包名称。

    ¥You can find the Package name in your app config under the android.package field.

  • 默认情况下,类名是 MainActivity,你可以使用 package.MainActivity,其中 package 是项目应用配置中的 android.package。例如,com.myapp.example.MainActivity,其中 com.myapp.example 是应用的 package 名称。

    ¥The Class name is MainActivity by default, and you can use package.MainActivity where package is the android.package in your project's app config. For example, com.myapp.example.MainActivity, where com.myapp.example is the package name of your app.

  • 然后,单击保存更改以保存配置。

    ¥Then, click Save changes to save the configuration.

现在,你可以使用 Facebook 项目来开发或发布构建和生产应用。

¥Now, you can use your Facebook project for development or release builds and production apps.

Expo 中文网 - 粤ICP备13048890号