# 1. Create Backend (Firebase)

## Add new Firebase Project&#x20;

1. Go to the [Firebase website](https://firebase.google.com/) and sign up for an account if you don’t already have one. You can log in with a Google account for easy access.&#x20;

When you log in, you should be directed to the Firebase console. You can manage all of your projects here. Go ahead and create a new one by clicking the blue **ADD PROJECT** button.

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LRHi_OXr9Ju61HlIDmK%2F-LRHlUFJlUs9p8QzEeel%2FScreenshot%20at%20Nov%2014%2021-35-17.png?alt=media\&token=c78344d0-ce5f-4f38-9c2b-ebdf0838cd1f)

2\. The "**Add a project**" window opens.

Enter the following information and click "CREATE PROJECT".

* Project name\
  Enter `Your name project`. This is the project name of your app in the Firebase console.
* Project ID *(Optional):*

  Firebase automatically assigns a unique ID to your Firebase project. This identifier displays in publicly visible Firebase services.
* Locations\
  Select your location. Hover on the "?" mark to display the description.

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LR_VmVjsUuoWyRZHOpE%2F-LR_WU1ZBBEMpxqa_D7r%2FScreen%20Shot%202018-11-18%20at%201.32.52%20PM.png?alt=media\&token=b3261d17-5daa-4386-928f-fc5f06fe5ea4)

Firebase automatically provisions resources for your Firebase project. The process typically takes a few minutes. When the process completes, you'll be taken to the overview page for your Firebase project in the Firebase console.

![Project Overview](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LR_WendRw0mfDEBNIzG%2F-LR_Wj5Q_tZZYsVv8sh0%2FScreen%20Shot%202018-11-18%20at%201.33.45%20PM.png?alt=media\&token=4ecb1dea-2bba-4cb7-b105-e54410be29af)

Now that you have a project, you can add your iOS and Android app to it:

## Add Firebase to your iOS project&#x20;

1. Click **Add Firebase to your iOS app** and follow the setup steps.&#x20;
2. When prompted, enter your app's bundle ID. It's important to enter the bundle ID your app is using; this can only be set when you add an app to your Firebase project.
3. During the process, you'll download a `GoogleService-Info.plist` file to add for XCode project later. You can download this file again at any time.
4. After you add the initialization code, run your app to send verification to the Firebase console that you've successfully installed Firebase.

![ iOS app](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LR_WendRw0mfDEBNIzG%2F-LR_XOBw1GSOFvjx061x%2FScreen%20Shot%202018-11-18%20at%201.36.45%20PM.png?alt=media\&token=a5455219-7bd9-431d-b5e9-386b131ec85e)

## Add Firebase to your Android app \*

1. Click **Add Firebase to your Android app** and follow the setup steps.
2. When prompted, enter your app's package name. It's important to enter the package name your app is using; this can only be set when you add an app to your Firebase project.
3. During the process, you'll download a `google-services.json` file. You can download this file again at any time.
4. After you add the initialization code, run your app to send verification to the Firebase console that you've successfully installed Firebase.

![Android App](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LR_WendRw0mfDEBNIzG%2F-LR_Xd-d0YINFJSZhNNl%2FScreen%20Shot%202018-11-18%20at%201.37.47%20PM.png?alt=media\&token=2fd05734-1c1d-4c03-9ad6-42c58c4a3bd9)

## **Config Database Rules**&#x20;

{% hint style="info" %}
This database will be used for both iOS and Android app.
{% endhint %}

1. Choose "Database" on the left menu. And click button **"Create database"**

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LRHxNjpJfKn-UKwri73%2F-LRHzS4Op9D6tkxU12pL%2FScreenshot%20at%20Nov%2014%2023-10-53.png?alt=media\&token=b4eaa9e5-3266-48c6-931d-3643cf6c7643)

2\. The "Security rules for Cloud Firestore" window opens. Select "**Start in locked mode**" and click **Enable** Button

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LRHxNjpJfKn-UKwri73%2F-LRI-oBJh73ZJct1F7hC%2FScreenshot%20at%20Nov%2014%2023-15-04.png?alt=media\&token=c39f3093-82d6-4b39-83ab-7d3e753c41ad)

3\. Then, Select "**Realtime Database**" in droplist and open tab "**Rules**".\
Paste bellow statement:\
`{` \
&#x20;   `"rules": {` \
&#x20;         `".read": true,` \
&#x20;         `".write": "auth !== null"` \
&#x20;   `}` \
`}`

Click Publish. Done.

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LRI23amtHT0Eu5cvKRQ%2F-LRI2VWZCL1Bv3xkoJXf%2FScreenshot%20at%20Nov%2014%2023-26-59.png?alt=media\&token=778ba3a1-7e21-4ef1-8b71-b48e0441e296)

## Import Trid Sample Data.&#x20;

1. In **Data** tab. Click icon more, choose Import JSON

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LR_WendRw0mfDEBNIzG%2F-LR_Z3e3ElGu0aqYm2OI%2FScreenshot%20at%20Nov%2018%2013-40-58.png?alt=media\&token=79cc8ffe-de20-40c4-912c-2398e23872b7)

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LR_WendRw0mfDEBNIzG%2F-LR__4d2MG8MDVK3kQri%2FScreenshot%20at%20Nov%2018%2013-48-43.png?alt=media\&token=fe6cdc9c-1e4d-4bb5-b726-4c1878333f57)

\
2\. The "**Import JSON**" window opens. Click **Browse** to Upload file (.json)

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LR_WendRw0mfDEBNIzG%2F-LR__pSnMftmN9nlPuFi%2FScreenshot%20at%20Nov%2018%2013-50-12.png?alt=media\&token=42a9206f-c362-4396-93bd-205d93ed549e)

{% hint style="info" %}
You can choose file "tridme-demo-export.json" in folder **"trid-package/admin-site/data-demo/"**

Or you can download here: <https://bit.ly/37Q0HmS>
{% endhint %}

3\. Click Import Button. Finish.

![Import successful data demo](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LR_b5KoAAGS4s38mF28%2F-LR_bOwE_9oR46-lcYoJ%2FScreen%20Shot%202018-11-18%20at%201.57.11%20PM.png?alt=media\&token=606c3f8d-2281-4347-82b8-fa41dca30a90)

## Enable Storage

{% hint style="info" %}
Enable Storage to upload images from Admin Site
{% endhint %}

1. Click Storage Menu in Sidebar
2. Click "Get Started" button

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LTwnMkC-n7G0VxmaBBF%2F-LTwoJDKDtJV6453d1Bt%2FScreenshot%20at%20Dec%2017%2022-37-17.png?alt=media\&token=09268e4d-5f03-4cb3-9183-30156bc0ed9d)

3\. Click "Goi it" button. Finish.

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LTwnMkC-n7G0VxmaBBF%2F-LTwoPgKGEUNgodSIan2%2FScreenshot%20at%20Dec%2017%2022-37-40.png?alt=media\&token=6ddcc51e-da25-4bd6-aeec-c6313615a540)

## **Add Authentication way**

{% hint style="info" %}
To users can register by email and facebook on Trid app. You must enable them in Authentication Firebase.
{% endhint %}

\
Choose "Authentication" on the left menu. Open tab "**Sign-in method**".\
Enable "**Email/Password**"&#x20;

![Enable Email/Password](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LRI3kQwbjZH898ht7YW%2F-LRI3pVMTT8LE2qMaTGq%2FScreenshot%20at%20Nov%2014%2023-33-54.png?alt=media\&token=3bba945f-029b-42e0-88f5-5f04fbbb7d74)

\
Enable "**Facebook**"&#x20;

Enter your facebook app id & enable this sign-in method

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LRI5XdB10mUDIklKzWy%2F-LRI5ao_-d0CeF4s_XVh%2FScreenshot%20at%20Nov%2014%2023-42-13.png?alt=media\&token=1e955042-b116-4896-8d89-30ad6a47bd8e)

#### How to create a Facebook app and get App ID?

1\. Go to Facebook developer site\
<https://developers.facebook.com/>

2\. Add new app

![Create new app with Name as you want](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LThEXYI72TpKsrk8qkj%2F-LThEyXe9nnQAeYSU77w%2Fassets--LNTaiB473xhWUmXbKi_--LPuSZQl9fZ4ALZy5VZg--LPuTYhHYuHQwTAfvhaJ-Screen%20Shot%202018-10-28%20at%206.40.36%20PM.png?alt=media\&token=c47a7e4f-a323-400a-b48e-89293f717c6d)

![](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LThEXYI72TpKsrk8qkj%2F-LThFd2KcHpKxIqtPjbO%2Fassets--LNTaiB473xhWUmXbKi_--LQ0FBnCrqKwxutqnuZJ--LQ0FGIjsBJUZp6fIZTx-Screen%20Shot%202018-10-30%20at%202.13.38%20AM.png?alt=media\&token=7bd2c385-2e23-4f0d-b45d-eadd6e97a8fd)

![Turn on the status to go live this app](https://3957173639-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNTaiB473xhWUmXbKi_%2F-LThEXYI72TpKsrk8qkj%2F-LThFizhqdsIB02o_gUf%2Fassets--LNTaiB473xhWUmXbKi_--LQ0FBnCrqKwxutqnuZJ--LQ0FpcgOp7n-4r1sKt0-Screen%20Shot%202018-10-30%20at%202.16.54%20AM.png?alt=media\&token=4eee1e70-9529-4bcf-b10f-dfd8221f248f)

#### You have done config for Firebase Backend. Go Next Step
