Push Notifications and Firebase Cloud Functions

Last updated 3 months ago

The final step is to write a cloud function to listen for database activity. To start, make sure that you have installed the Firebase CLI and login.

$ npm install -g firebase-tools $ firebase login

Then cd into your project directory and run:

$ firebase init

When it prompts you to install node modules return yes. Once the script completes, in your React Native project you should now have a new folder: functions

Open < Firebase_functions_pushNotification_Script> and copy <index.js> and replace the <index.js> inside the functions folder created.

Then run the following commands:

$ cd /<yourprojectdirectory>/ $ firebase deploy

This uploads your function to Google’s servers.

And check the logs too for any activity: