{"id":20008958,"url":"https://github.com/chat-sdk/chat-sdk-firebase","last_synced_at":"2025-05-04T19:35:38.722Z","repository":{"id":47120501,"uuid":"198202949","full_name":"chat-sdk/chat-sdk-firebase","owner":"chat-sdk","description":"Firebase scripts and rules","archived":false,"fork":false,"pushed_at":"2021-05-05T09:01:54.000Z","size":48,"stargazers_count":21,"open_issues_count":3,"forks_count":32,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T11:37:59.953Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chat-sdk.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-22T10:43:38.000Z","updated_at":"2023-11-29T15:09:58.000Z","dependencies_parsed_at":"2022-09-04T11:52:28.864Z","dependency_job_id":null,"html_url":"https://github.com/chat-sdk/chat-sdk-firebase","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chat-sdk%2Fchat-sdk-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chat-sdk%2Fchat-sdk-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chat-sdk%2Fchat-sdk-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chat-sdk%2Fchat-sdk-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chat-sdk","download_url":"https://codeload.github.com/chat-sdk/chat-sdk-firebase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252390536,"owners_count":21740340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T07:13:24.151Z","updated_at":"2025-05-04T19:35:38.442Z","avatar_url":"https://github.com/chat-sdk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Firebase Environment Setup\n\nThere are a few steps you need to complete to get your Firebase environment ready:\n\n1. Setup Push Notifications\n2. Enable the security and search rules\n3. Enable the storage rules\n\n## Enable Push Notifications\n\nTo handle push notifications, we use [Firebase Cloud Functions](https://firebase.google.com/docs/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. \n\nBelow 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](https://firebase.google.com/docs/functions/get-started). \n\n1. Clone this repository to your computer\n2. Navigate to the directory in terminal\n3. Run `firebase login` and login using the terminal\n6. Run `firebase init`\n4. Select Database, Functions and Storage\n5. Select \"Use an existing project\"\n7. Choose the correct app from the list\n8. \"What file should be used for Database Rules? (database.rules.json)\" `Enter`\n9. \"File database.rules.json already exists. Do you want to overwrite...\" `N`\n10. Repeat `N` for all files\n8. Choose `JavaScript`\n9. Choose `y` for ESLint\n10. File ... already exists. Overwrite? `N` \n11. \"Do you want to install dependencies with npm now?\" `Y`\n12. \"What file should be used for Storage Rules? (storage.rules)\" `Enter`\n13. \"Overwrite?\" `N`\n11. Find the `functions` directory you've just created and add the files: `index.js` and `package.json` from [Github](https://github.com/chat-sdk/chat-sdk-firebase/tree/master/functions) \n12. Run `npm install`\n13. Make sure the flag `enableV4Compatibility` matches the value used in your project\n14. If you are using the user blocking module ensure that the variable in the script `blockedUsersEnabled` is set to `true` \n15. Run `firebase deploy` \n\nNow the script is active and push notifications will be set out automatically. \n\n## Deploy the Firebase rules\n\nFirebase 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. \n\nCopy the contents of the [**database.rules.json**](https://github.com/chat-sdk/chat-sdk-firebase/blob/master/database.rules.json) file into the rules and click publish.\n\n**OR**\n\nMake sure your `firebase.json` file is follows:\n\n```\n\"database\": {\n  \"rules\": \"database.rules.json\"\n}\n```\n\nRun:\n\n```\nfirebase deploy --only database:rules\n```\n\n### Bolt\n\nThe rules are written in bolt which is a language that makes it easier to write the rules. We include an up-to-date version of the rules in the `chat-sdk-rules.json` file but if you want to update the rules yourself, you should edit the `rules.bolt` file. \n\nInstall [Bolt](https://github.com/FirebaseExtended/bolt/blob/master/docs/guide.md):\n\n```\nnpm install --g firebase-bolt\n```\n\nThen run:\n\n```\nfirebase-bolt database.rules.bolt\n```\n\nThis will generate a `rules.json` file which you can add to your project from the Firebase console. \n\nYou can also update your `firebase.json` to:\n\n```\n\"database\": {\n    \"rules\": \"database.rules.bolt\"\n},  \n```\n\n## Deploy the storage rules\n\nMake sure storage is enabled for your project. On the Firebase dashboard click **Storage** and follow the instructions to enable storage.\n\nThe storage rules are needed to enable image storage and upload for image messages and user profiles. \n\nUpdate your `firebase.json` file as follows:\n\n```\n\"storage\": {\n\t\"rules\": \"storage.rules\"\n}\n```\n\nRun:\n\n```\nfirebase deploy --only storage\n```\n  \n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchat-sdk%2Fchat-sdk-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchat-sdk%2Fchat-sdk-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchat-sdk%2Fchat-sdk-firebase/lists"}