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

Enable Push Notifications

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. Clone this repository to your computer
  2. Navigate to the directory in terminal
  3. Run firebase login and login using the terminal
  4. Run firebase init
  5. Select Database, Functions and Storage
  6. Select "Use an existing project"
  7. Choose the correct app from the list
  8. "What file should be used for Database Rules? (database.rules.json)" Enter
  9. "File database.rules.json already exists. Do you want to overwrite..." N
  10. Repeat N for all files
  11. Choose JavaScript
  12. Choose y for ESLint
  13. File ... already exists. Overwrite? N
  14. "Do you want to install dependencies with npm now?" Y
  15. "What file should be used for Storage Rules? (storage.rules)" Enter
  16. "Overwrite?" N
  17. Find the functions directory you've just created and add the files: index.js and package.json from Github
  18. Run npm install
  19. Make sure the flag enableV4Compatibility matches the value used in your project
  20. If you are using the user blocking module ensure that the variable in the script blockedUsersEnabled is set to true
  21. 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 database.rules.json file into the rules and click publish.

OR

Make sure your firebase.json file is follows:

"database": {
  "rules": "database.rules.json"
}

Run:

firebase deploy --only database:rules

Bolt

The 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.

Install Bolt:

npm install --g firebase-bolt

Then run:

firebase-bolt database.rules.bolt

This will generate a rules.json file which you can add to your project from the Firebase console.

You can also update your firebase.json to:

"database": {
    "rules": "database.rules.bolt"
},  

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": "storage.rules"
}

Run:

firebase deploy --only storage

chat-sdk-firebase's People

Contributors

bensmiley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chat-sdk-firebase's Issues

.

.

Image is not deleted from storage

Tested this in Android and iOS.

steps to replicate

  1. send image from with in the app.
  2. The file appears in firebase>>Storage>>files
  3. now delete the image from the app.
  4. The file remains in the firebase server.

Facing issue when deploying to firebase using the terminal

Hi

I have followed your tutorial video step by step but I am getting issue at the point when i am about to deploy it to firebase console I have attached the screenshot of the issue

Screenshot 2021-01-28 at 2 23 23 AM

Please let me know i have been stuck at this point from past 2 days

Deployment success but won't reflect on the dashboard.

The deployment in the CLI says โœ” Deploy complete!. But there's no update on the Firebase Functions Dashboard. I tried this multiple times already. In other project, I was able to deploy the functions that I have pretty easily.

Screen Shot 2020-01-06 at 1 25 28 PM

IOS - [FIRApp configure] not called on newly created target

Hi,

I have an existing project that already contains Firebase implementations ( pod 'Firebase/Analytics', pod 'Firebase/Crashlytics'), so when I implemented chatSDK, I removed old FirebaseApp.configure and I'we let ChatSDK do the config. And it is working fine, but only on my main project target. I have two more derived targets, both from main target, one for development (uses different google.services), and one exactly the same as my main target (uses the same google.services as main target). The problem is that FirebaseApp.configure ([FitApp config]) is never called. So the only thing I am changing is the target, the code is absolutely the same - except for dev target where set different config.firebaseGoogleServicesPlistName.
I have identified the root of the problem in BModuleHelper.m in currentServer method. Main target gets bServerFirebase for current server, and other targets drop to defaultServer option, and cause of that BFirebaseNetworkAdapter's init method never gets called.

My pod file:


# Uncomment the next line to define a global platform for your project
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '13.0'


target 'scoutone-ios' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for scoutone-ios

  pod 'Firebase/Analytics'
  pod 'Firebase/Crashlytics'
  pod 'Firebase/Messaging'
  pod "ChatSDK", '~> 4.15.8'
  pod "ChatSDKFirebase/Adapter", '~> 4.15.8'
  pod "ChatSDKFirebase/FileStorage", '~> 4.15.8'
  pod "ChatSDKFirebase/Push", '~> 4.15.8'

  target 'scoutone-iosDEV' do
    inherit! :search_paths
    use_frameworks!
    
   pod 'Firebase/Analytics'
   pod 'Firebase/Crashlytics'
   pod 'Firebase/Messaging'
   pod "ChatSDK", '~> 4.15.8'
   pod "ChatSDKFirebase/Adapter", '~> 4.15.8'
   pod "ChatSDKFirebase/FileStorage", '~> 4.15.8'
   pod "ChatSDKFirebase/Push", '~> 4.15.8'

  end
  
  target 'scoutone-ios ChatDev' do
    inherit! :search_paths
    use_frameworks!
    
    pod 'Firebase/Analytics'
    pod 'Firebase/Crashlytics'
    pod 'Firebase/Messaging'
    pod "ChatSDK", '~> 4.15.8'
    pod "ChatSDKFirebase/Adapter", '~> 4.15.8'
    pod "ChatSDKFirebase/FileStorage", '~> 4.15.8'
    pod "ChatSDKFirebase/Push", '~> 4.15.8'

  end
  
  target 'scoutone-iosTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

EDIT:
This is a swift project

EDIT1:
I did some digging, and it seams that cocoapods don't insert
-framework "ChatSDKFirebase"
in OTHER_LDFLAGS of derived targets.

pushListener not called on new messages

Hello.

Precondition:
All Firebase setup steps are executed with no errors and firebase functions are listed on Functions page.

Problem:
pushListener function is not called when a new message is added to Realtime Database.

Observation:
running a function test using Google Cloud Platform testing UI produces an error:
TypeError: Cannot read property 'from' of null

the error is reported on this line:
const senderId = messageValue["from"];

Firebase deploy error

While deploying my project, I get the following error.
Screenshot from 2021-05-05 12-58-05

I was following the tutorial on your youtube and I am not able to proceed.

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.