Receiving a notification

  • FCM

    Firebase Cloud Messaging allows you to send push notifications to your users directly from your app.

    Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user reengagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.

    If you don’t have FCM integrated with your app yet, you have to configure Push Notification by visiting

    Register token updates

    You don’t have to register FCM token. SDK will do it for you.

  • Passing notification to SDK

    In your service which extends FirebaseMessagingService, pass the notification to SDK

    public class FcmService extends FirebaseMessagingService {
        public void onMessageReceived(RemoteMessage remoteMessage) {
            UserCom.getInstance().onNotification(getApplicationContext(), remoteMessage);
  • Remember to initialize your service in AndroidManifest.xml:

          <action android:name="" />

    SDK will use only notifications containing user_com_notification tag, so if you have already FCM in your project, SDK will not interfere with existing notifications.

  • Pass notification clicked event

    To pass notification clicked event to web panel you must include handleRouteFromNotification() function in your android.intent.category.LAUNCHER activity. We recommend to use it in Activity.onCreate() method.

  • Handling notifications
    Manually handle notification

    You can receive UserComNotification object from Activity.getIntent() or Simply use UserComNotification.create() factory.

    Receiving notification from Activity looks like:

    @Nullable UserComNotification notification =

    and from FirebaseMessagingService.onMessageReceived() like this:

    @Nullable UserComNotification notification =

    These creators return null if passed data does not contain user_com_notification key, so you can use this safely with your own notifications.

  • In-app message

    In-app message will be displayed as default Alert Dialog. Because it’s created without any theme, it will be necessary to style this Dialog to match your app style.

  • In-app dialog buttons

    If you pass a link parameter to in-app push data, then an in-app dialog will show two buttons

    • negative to dismiss dialog with @string/user_com_in_app_message_close_button text
    • positive with text from action_button_title parameter

    If the link parameter will be empty, then only positive button with action_button_title text will be displayed.

    To change default “Close” button just override specific string in values/strings.xml.

    <string name="user_com_in_app_message_close_button">Dismiss</string>
  • Stylize in app dialog

    To change positive button color override user_com_in_app_message_dialog_positive color in values/colors.xml:

    <color name="user_com_in_app_message_dialog_positive">@color/accent</color>

    Remember to pass color explicit without using ?attr value.

    You can also style in app dialog overriding one of below styles using by SDK:

    • - positive button style
    • <style name="" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
          <item name="android:textColor">@color/user_com_in_app_message_dialog_positive</item>
    • - negative (Close) button style
    • <style name="" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
          <item name="android:textColor">?android:textColorSecondary</item>
    • - a whole in app dialog style
    • <style name="" parent="Theme.AppCompat.Light.Dialog.Alert">
          <item name="buttonBarPositiveButtonStyle">@style/</item>
          <item name="buttonBarNegativeButtonStyle">@style/</item>
  • Chrome Custom Tabs

    If In-App Message contains link parameter and the user clicks on positive Dialog button, then he will be redirected to the browser. By default, it will be Chrome Custom Tabs that you can customize to match your app style by invoking a UserCom.Builder.setCustomTabsBuilder(CustomTabsIntent.Builder) function:

    public void onCreate() {
        new UserCom.Builder(…)
    private static CustomTabsIntent.Builder getCustomTabsBuilder() {
        CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
        return builder;
  • You can also disable this feature permanently using UserCom.Builder.openLinksInChromeCustomTabs(boolean) method: