Git Product home page Git Product logo

chat-sdk-firebase's Introduction

Firebase Environment Setup

There are a few steps you need to complete to get your Firebase environment ready:

  1. Setup Push Notifications
  2. Enable the security and search rules
  3. Enable the storage rules

Setup Firebase Cloud Functions

To handle push notifications, we use Firebase Cloud Functions. This service allows you to upload a script to Firebase hosting. This script monitors the realtime database and whenever a new messsage is detected, it sends a push notification to the recipient.

Below is a summary of the steps that are required to setup push using the Firebase Cloud Functions script. For further instructions you can look at the Firebase Documentation.

  1. Run firebase login and login using the browser
  2. Make a new directory to store your push functions in. It can be called anything
  3. Navigate to that directory using the terminal
  4. Run firebase init functions
  5. Choose the correct app from the list
  6. Choose JavaScript
  7. Choose y for ESLint
  8. Choose Y to install node dependencies
  9. Find the functions directory you've just created and add the files: index.js and package.json from Github
  10. If you are using the user blocking module ensure that the variable in the script blockedUsersEnabled is set to true
  11. Run firebase deploy

Now the script is active and push notifications will be set out automatically.

Deploy the Firebase rules

Firebase secures your data by allowing you to write rules to govern who can access the database and what can be written. On the Firebase dashboard click Database then the Rules tab.

Copy the contents of the rules.json file into the rules and click publish.

OR

Update your firebase.json file as follows:

"database": {
  "rules": "chat-sdk-rules.json"
}

Copy the chat-sdk-rules.json file into your project directory then run:

firebase deploy --only database:rules

Deploy the storage rules

Make sure storage is enabled for your project. On the Firebase dashboard click Storage and follow the instructions to enable storage.

The storage rules are needed to enable image storage and upload for image messages and user profiles.

Update your firebase.json file as follows:

"storage": {
	"rules": "chat-sdk-storage-rules.json"
}

Copy the chat-sdk-storage-rules.json file into your project directory then run:

firebase deploy --only storage

chat-sdk-firebase's People

Contributors

bensmiley avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.