Create a Firebase Console App
-----------------------------------------------------------------------
Login to https://console.firebase.google.com/ and create a new project
Give a project name continue
From the project settings go to the “Service Account” tab and generate new private key
On click of “Generate new private key” button, your service key json file will be downloaded locally. Save the file for future use.
Go to the “General” tab and add your app (Web, mobile).
Come back to the “General” tab and you will get the information and keys for the app recently created.
Go to the “Cloud Messaging” tab and enable “Firebase Cloud Messaging API (V1)”. Click on “Manage Service Accounts” link. You can see the details of your service account and it is already enabled.
In the same tab bellow, click on the “Generate Key Pair” to create web push certificate which is called “VapidKey”
Your configuration is ready.
A] Service account json file will be used to configure Admin SDK for message sending
B] Private Key and VapidKey will be used to configure client to receive message.
Use the Firebase Push Notification v1 library in ODC to send and receive message
Content of “Firebase Lib”
--------------------------------------
A] Web block to receive message
B] Server action to send message
Configure client:
-----------------------------------
Add the reference of “Firebase Lib” in your application. Drag the “Firebase Receiver” block to your page or common layout.
Provide values to parameters and handle the events. From 2nd to 8th parameters are available in your firebase console app (follow page 3). ApplicationName should be your application name.
Handle the events. If new device token is generated then it will be received in GetToken. If any message is coming then it will be received in ReceiveMessage.
Receive message gets the Payload structure type data where title, body and data are available. If any additional data is provided then it will be available inside data.
Add background service worker java script file inside resource folder of your application and set deploy action to target directory. You can give any name to the worker js file and use the same name in the firebase receiver block last parameter “ServiceWorkerJsFileName”.
** You can download the worker js file from resource folder of firebase lib as zip. Unzip the file and use it.
Configure server:
--------------------------------------------------------------------
Go to your ODC portal and set the firebase lib settings inside your application. All these keys are available in your service account json file (follow page 2). Scopes should be the same as given in the image bellow.
Format your private key –
Copy the private key text from json file and put in notepad. Remove all ‘/n’ and press enter for new line. Copy the text and paste in the “PrivateKey” under application settings.
User of server actions to send message –
This function is used to send a message to a single device.
This function is used to send message to multiple device. It takes the device token as list.
This function is used to send message to a topic where already multiple devices are subscribed. Here device
token is not required.
Device can subscribe a topic with a specific name
Device can unsubscribe a topic with a specific name
Send additional data –
In send functions (SendMessage, SendMessageToMultiple, SendToTopic), Data input parameter can be used to send additional data to the message. It takes text type. If you have complex data type to be send, you can send it as a json text and de-serialize the json to structure defined in your application level.