Firebase Cloud Messaging
Firebase Cloud Messaging (FCM) is Google's free push notification service. Easy Chat Room can use it to send push notifications for private messages to members' browsers and installed apps.
Create a Firebase project
- Sign in to the Firebase console with a Google account and click Add project.
- In the project, open Project settings > General and add a Web app. Firebase shows its configuration:
apiKey,projectId,messagingSenderIdandappId. Copy these four values. - Open Project settings > Service accounts and click Generate new private key. Firebase downloads a JSON file. Keep it safe: it gives full access to sending messages for your project.
Set up in Easy Chat Room
- Go to Settings > Notifications.
- Set Enable Push Notifications to Yes and Push Provider to Firebase.
- Open the downloaded JSON file in a text editor, copy all of its content and paste it into Firebase Service Account JSON.
- Fill in Firebase Messaging Sender ID, Firebase API Key, Firebase Project ID and Firebase App ID from the web app configuration.
- Click Update.
Test it
- Log in on the site with a member in one browser, open the chat and allow notifications when the browser asks.
- Close that tab.
- Send that member a private message from another account.
A notification with the sender's name should appear. A click opens the conversation.
Notes
- Push needs HTTPS.
- The browser registers with Firebase the first time a logged-in member opens the chat page. Each member gets notifications on the last device that registered.
- The service account JSON stays on your server. Only the web app values are sent to the browser.