Firebase Cloud Messaging (FCM) integration is necessary to send push messages to Android devices. To do it you have to implement FCM server key and json in FAMOC Configuration tool. To complete the process , you will also need the existing Google Cloud Messaging GDC project number which can be found in the current settings of the “famoc-config” tool under System configuration> Other push services.
NOTE: Before you start FCM configuration for FAMOC server, you need to add outgoing rule from FAMOC server to Internet for TCP requests https://fcm.googleapis.com/fcm/send for port 443.
First, login to Firebase console: https://console.firebase.google.com/ with the same credentials as used for GCM configuration and add new project.
Choose existing GCM project from dropdown menu. If you want to edit Analytics location click button (You can read more about project location settings on FCM support page: https://firebase.google.com/support/guides/locations).
NOTE: It is not required to use default settings for sharing Google Analytics data. If you unmark this checkbox, Continue button will replace Create project button. If you click on it, additional step allowing you to customize data sharing will appear.
To finish the process click Add Firebase.
After a while you will see confirmation message. Click Continue.
To register new app click the Android icon .
Enter the name of the new app. By default it is com.famoc.baseAgent. Other steps are optional so you can click Register app button and click the X button in the top left corner or Next, Next, Skip to close the window.
Enter the Project settings by clicking clockwork icon.
In the next window click Add app.
From given options select Android.
Repeat all the steps but this time set the Android package name as com.fancyfon.baseAgent.
Click again clockwork icon nad go to Project settings > General tab and download google-services.json file.
Then go to Cloud Messaging tab and copy Server key Token.
Now, run the FAMOC Configuration Tool and go to Configuration > Firebase push service menu.
NOTE: If you see more agents than those added in previous steps, you have to add them in Google web console and download google-services.json file again.
Paste Server key you previously copied from Cloud Messaging settings on firebase.google.com in FCM Server key field. Check if Google Cloud Messaging GDC project number we mentioned before is identical as FCMSender ID.
Open previously downloaded .json file in Notepad and copy the whole content. Paste copied content in JSON:_____ field, which will be shown when you select Paste FCM JSON file button and click OK.
NOTE: Sometimes a problem occurs when copying JSON file content on macOS and Linux machines. To avoid it you have to remove the end of line symbol from file using command:
cat google-services.json | tr -d '\n'
tr -d '\n' < google-services.json > Downloads/no-n.json command
If you have correctly performed the above operations, all fields should be completed as shown below (the values have been blurred for security reasons). The last agent (com.plus.android.info) appeared as an example of subsequent agents that may appear on the list depending on the functionalities implemented on the server. In the standard version, the first two will appear. FCM Web API Key and App IDs will be completed automatically after pasting the correct .JSON file.
To finish click Save.
Go back to FAMOC Configuration tool Main Menu and select FINISH & SAVE CONFIG.
To verify if the integration have been performed correctly add:
topic: Android push debug: android.log
Then enter the command:
killall -HUP fflogd
Send push to an Android device (e.g. initiate Usage Monitor from FAMOC web console) and execute:
cat /var/log/famoc/android.log | grep -i fcm
This command will display log with FCM message:
Signal sent to Android Push Notification service over FCM
This message indicates that integration have been performed correctly. In case of failure, messages may be displayed:
We couldn't send FCM message as Registration Device Identifier is INVALID or DOES NOT EXIST
FCM message could not be sent: (ERROR DESC)
This is most commonly due to different GCM ID and FCM ID.