使用 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:
安卓配置
🌐 Configuration for Android
在你的 Facebook 项目中添加 Android 作为平台,需要你的应用获得 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:
一旦你将应用上传到 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 平台。你需要提供 Key hash、包名和类名。
🌐 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.
- 要添加 Key hash,请前往你的 Play 商店控制台,从 发布 > 设置 > 应用完整性 > 应用签名密钥证书 获取 SHA-1 证书指纹。然后,将证书的十六进制值转换为 Base64,并将其添加到你 Facebook 项目的 Android > Key hashes 下。
- 你可以在你的 应用配置 的
android.package字段中找到包名。 - 默认情况下,类名是
MainActivity,你可以在项目的应用配置中使用package.MainActivity,其中package是android.package。例如,com.myapp.example.MainActivity,其中com.myapp.example是你应用的package名称。 - 然后,点击 保存更改 以保存配置。
现在,你可以使用 Facebook 项目来开发或发布构建和生产应用。
🌐 Now, you can use your Facebook project for development or release builds and production apps.