generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e63b767
commit 04b6f98
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Firebase Functions Documentation 📚 | ||
|
||
In this section, we'll explore how to use Firebase Functions. They're a crucial part of our system. Let's dive in! 🚀 | ||
|
||
## Getting Started with Firebase Functions Locally 🏁 | ||
|
||
To run Firebase Functions locally, follow these steps: | ||
|
||
1. **Install the Firebase CLI** - Essential for both local development and deployment. [Learn more here](https://firebase.google.com/docs/cli) 🛠️ | ||
2. **Login to Firebase CLI** - Necessary only if you plan to deploy your functions. 🔑 | ||
3. **Select the Project** - Required if you're deploying the functions. 📂 | ||
4. **Confirmation** - To confirm the Firebase CLI is correctly installed, open your terminal and run: `firebase --version` ✅ | ||
|
||
## Running the Firebase Functions Emulator 🚀 | ||
|
||
To get the Firebase Functions Emulator up and running, follow these steps: | ||
|
||
1. **Install Emulators** - If not already done, you may need to install the necessary emulators. [Learn more here](https://firebase.google.com/docs/emulator-suite/install_and_configure) 📦 | ||
2. **Initialize Emulators** - Run `firebase init emulators` to set up the emulators in your project. This step helps configure the emulators according to your project's needs. 🛠️ | ||
3. **Start the Emulator** - From the root of your repository, run `firebase emulators:start --only functions` to start the emulator. 🖥️ | ||
|
||
That's it! You're all set. All details related to the status and logs of your Firebase Functions will be available in the console once the functions start working. Keep an eye on the console for real-time updates and debugging information. 🎉 | ||
|
||
## Working with Firebase Emulator and React Native 📱 | ||
|
||
Working with the Firebase emulator and React Native can be challenging due to the servers running on different systems. The Firebase Functions run on your local machine, while the emulator or testing device runs on your phone or inside the machine. This setup leads to different `localhost` environments, making it impossible to access the functions directly from your phone. | ||
|
||
## Overcoming Localhost Issues with Firebase and React Native 🌉 | ||
|
||
To address the challenge of different localhost environments between the Firebase emulator (running on your local machine) and your React Native app (running on a phone or emulator), we've implemented a solution using HTTP callable functions. | ||
|
||
### Testing with HTTP Callable Functions 🧪 | ||
|
||
1. **Create HTTP Callable Functions**: These functions can be invoked via HTTP requests, making them accessible regardless of the `localhost` issue. | ||
2. **Testing with Postman or Thunder Client**: Before integrating with your React Native app, test the HTTP callable functions using tools like Postman or Thunder Client, both available as VS Code extensions. This ensures the functions behave as expected. | ||
|
||
### Deployment 🚀 | ||
|
||
- **Why Deployment is Necessary**: For your React Native app to access the Firebase Functions, you must deploy them. This is because the app can only interact with deployed functions, bypassing the localhost discrepancy issue. | ||
|
||
By following these steps, you can effectively bridge the gap between your Firebase Functions and React Native app, ensuring a smooth development and testing process. |