Advanced features
FCM (Firebase Cloud Messaging) is a free service from Google that lets users reliably deliver push notifications to web or android devices.For more information on FCM please see the following documentation.
MQTTchat uses FCM for two purposes:
- Send notifications when MQTT messages or MQTT notifications are received and the android application is closed.
- Route audio and video calls when the application is closed.
FCM feature is not activated by default, to activate it for your application, you must follow the following steps:
First you need to setup your app to firebase console to get a google-serivces.json file. Then you need to add this file to your project under app package.
Once the json file is added you need to add the Firebase dependencies. In the project's build.gradle:
buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:4.3.3'
}
}
And at the bottom of the app's build.gradle add:
apply plugin: 'com.google.gms.google-services'
That is all. MQTT chat takes care of others configs and use of FCM in source code.
Now you need to add your FCM server key to your MQTT chat Admin Panel to allow our MQTT servers to send notifications to your users' devices.
You can get the server key from the FCM firebase console /project/settings/cloud Messaging/server key.
You can customize MQTT chat GUI colors to match your android application theme. Below differents color variables used by MQTT chat:
Color name |
mqttchat_colorPrimary |
mqttchat_colorPrimaryDark |
mqttchat_colorAccent |
mqttchat_textColorPrimary |
mqttchat_textColor |
mqttchat_tabtextActiveColor |
mqttchat_tabtextColor |
mqttchat_windowBackgroundColor |
mqttchat_sendMessageBoxBackgroundColor |
mqttchat_contactNameColor |
mqttchat_pluginsToolbarColor |
mqttchat_contactLastMessageNormalColor |
mqttchat_contactLastMessageNotReadColor |
mqttchat_listviewBackgroundIdleColor |
mqttchat_listviewBackgroundPressedColor |
mqttchat_contactNotReadMessagesCountBackgroundColor |
mqttchat_contactNotReadMessagesCountColor |
To edit a color to match your application theme, you need to overrite the value of color variable in your app color.xml ressource file.
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#008577</color>
<color name="mqttchat_colorPrimary">#008577</color>
<color name="mqttchat_colorAccent">#008577</color>
<color name="mqttchat_textColorPrimary">#FFFFFF</color>
<color name="mqttchat_pluginsToolbarColor">#008577</color>
</resources>
You can use Callbacks URLs feature to save sent messages or user's presence status in your android application and then show list of online users or filter users by presence status.