Purpose: We used cloud function for sending push notification for user based on some triggers like new messages, group creation..etc
Before doing firebase setup, we need to install firebase tools on your machine. To do that, please execute
npm install -g firebase-tools
mkdir fcf
cd fcf
firebase login
firebase init functions
It might asks your few questions, please answer as followed
- Choose your firebase project
- Language: JavaScript
- EsLint: No
- Npm install: Yes
Then, we need to follow these steps,
cd functions
npm install --save firebase-admin
npm install --save firebase-functions
npm install --save request
After installation, we need to replace newly created index.js file with downloaded (purchased) index.js;
- Rename downloaded files to
service-account-key.json
- Copy your
service-account-key.json
tofcf/functions/
- Open
fcf/functions/index.js
with any text editor & Update your databaseURL
cd ..
firebase deploy --only functions
Note: You must be inside fcf/ (not inside fcf/functions) folder for deploying.
After deployment, you can see CustomTokenURL on console, which you need to update with your project/src/settings.ts