REACT NATIVE FIREBASE
(REACT – NATIVE)
1
1
REACT NATIVE FIREBASE
Firebase là một dịch vụ lưu trữ cơ sở dữ liệu thời gian
thực hoạt động trên nền tảng đám mây được cung cấp
bởi Google nhằm giúp các lập trình phát triển nhanh các
ứng dụng bằng cách đơn giản hóa các thao tác với cơ
sở dữ liệu.
3
Prerequisites
Before getting started, you are able to create a project
with React Native and that you have an active Firebase
project
React Native - Setting up the development
environment
Create a new Firebase project
Note:
React Native Firebase cannot be used in the "Expo Go"
app, because it requires custom native code.
Integration with Expo is possible in both bare workflow
and custom managed workflow via config plugins.
4
Prerequisites
Create React Native App
npx react-native@latest init DemoReactNativeFireBase
Create Expo App
npx create-expo-app DemoReactNativeFireBase
cd AwesomeProject
5
Generate native projects in Expo
npx expo prebuild
npx expo run:android
npx expo run:iOS
6
Create a new Firebase project
Click android or iOS
7
Android Setup
To allow the Android app to securely connect to your
Firebase project, a configuration file must be
downloaded and added to your project.
8
Create a new Firebase project
9
Create a new Firebase project
10
Generate native projects in Expo
Download the google-
services.json file and place it
inside of your project at the
following location:
/android/app/google-
services.json.
11
Create a new Firebase project
Note: The debug signing certificate is optional to use Firebase with your app, but
is required for Dynamic Links, Invites and Phone Authentication. To generate
a certificate run
cd android && ./gradlew signingReport
12
Configure Firebase with Android credentials
First, add the google-services plugin as a dependency inside of your
/android/build.gradle file:
Lastly, execute the plugin by adding the following to your
/android/app/build.gradle file:
13
Installation
Install via NPM
14
Autolinking & rebuilding
Users on React Native 0.60+ automatically have access
to "autolinking", requiring no further manual installation
steps. To automatically link the package, rebuild your
project:
Run expo: npm run android
Run react native in expo , creating a metro.config.js file
at the root of your project
npx expo customize metro.config.js
npx react-native run-android
15
Cloud Firestore
Installation
npm install @react-native-firebase/app @react-native-firebase/firestore
16