Monday, 27 March 2017

Using Cloud Functions in Firebase to send emails to the users for subscriber notifications

Use the GitHub repository:

1. Copy or clone the repository in your computer.
2. Move the functions to the functions folder created for your Project in the local directory and move the hosting files in public folder to the local public folder.
3. Paste the Web initialization snippet from: Firebase Console > Overview > Add Firebase to your web app in the public/index.html where the TODO is located.
4.You must have the Firebase CLI installed. If you don't have it install it with  install -g firebase-tools and then configure it with firebase login.


5. Configure the CLI locally by using firebase use --add and select your project in the list.
6. Install dependencies locally by running: cd functions; npm install; cd -
7. Now open the command prompt / terminal and enter the following command by changing the your-email@gmail.com and email-password from which you want to send the email.

firebase functions:config:set gmail.email="your-email@gmail.com" gmail.password="email-password"

This will configure the 'gmail.email' and 'gmail.password' Google Cloud environment variables.
8. After its done, now its time to deploy your functions and hosting for the project.
9. Open the command prompt/terminal. Use the command

firebase deploy

To start the deployment.

10. After the deployment is complete you can open the hosting from the URL displayed in terminal at the end of the deployment completion.

No comments:

Post a Comment