Logo Site EngageLab Mark Colored TransparentDocument
Search

How to Prevent Messages from Being Collapsed

In mobile app push notification scenarios, message collapsing directly affects the user experience and message delivery efficiency. Based on the AppPush product, this article explains in detail how to achieve non-collapsed message display through technical configuration, covering both Notification and Custom Message types.

alt text

1. Comparison of Message Types and Display Rules

Notification

  • System default behavior:
App Status Display Rule
Running in foreground Collapse logic can be controlled through group_id
Running in background Handled by the mobile operating system. By default, messages appear in the notification bar, and the display format is restricted (such as collapsing, quantity limits, etc.), making custom styling difficult.
  • Applicable scenarios: Standard push notifications that need to reach users through the system notification bar.

Custom Message

  • Core advantage:
    Whether the app is in the foreground, background, or has been cleared with one tap, the message display format can be fully controlled through client-side code, including popup position and collapse logic.

  • Applicable scenarios:
    High-priority messages that require customized interaction, such as order status reminders and instant chat messages.

2. Two Solutions to Prevent Messages from Being Collapsed

Solution 1: Using Notification

(For the FCM channel, the app must be in the foreground; the EngageLab channel does not distinguish between foreground and background.)

Implementation principle

Use the group_id field to control message grouping logic:

  • No collapsing: assign a unique group_id to each message.

Steps

Supported versions: Android SDK V5.0.1 and later

Example of push API parameter configuration (request body):

{ "notification": { "android": { "group_id": "UNIQUE_GROUP_123" // Use a unique value to prevent collapsing } } }
              
              {
  "notification": {
    "android": {
      "group_id": "UNIQUE_GROUP_123"  // Use a unique value to prevent collapsing
    }
  }
}

            
This code block in the floating window

Compatibility notes

  • Only FCM and EngageLab push channels are supported.
  • If the app is running in the background, message display is still subject to system restrictions.

Solution 2: Using Custom Message (Supported in All Scenarios)

Implementation principle

Actively call the showNotification API on the client side to fully control the message rendering logic and avoid system restrictions.

Steps

1. Send a custom message
{ "message": { "msg_content": "Your order has been shipped", "content_type": "text", "extras": { "type": "priority_alert", "style": "popup_bottom" // Custom display style } } }
              
              {
  "message": {
    "msg_content": "Your order has been shipped",
    "content_type": "text",
    "extras": {
      "type": "priority_alert",
      "style": "popup_bottom"  // Custom display style
    }
  }
}

            
This code block in the floating window
2. Process the message on the client side (Android example)
public class UserReceiver extends MTCommonReceiver { @Override public void onCustomMessage(Context context, CustomMessage customMessage) { ExampleLogger.i(TAG, "onCustomMessage:" + customMessage.toString()); showNotification(context, customMessage); // Call display logic } }
              
              public class UserReceiver extends MTCommonReceiver {
    @Override
    public void onCustomMessage(Context context, CustomMessage customMessage) {
        ExampleLogger.i(TAG, "onCustomMessage:" + customMessage.toString());
        showNotification(context, customMessage); // Call display logic
    }
}

            
This code block in the floating window
3. Example of custom display logic (to prevent collapsing)
public void showNotification(Context context, CustomMessage customMessage) { NotificationMessage notificationMessage = new NotificationMessage() .setMessageId(customMessage.getMessageId()) .setNotificationId("Define this yourself, but make sure each notification is different") .setTitle(customMessage.getTitle()) .setContent(customMessage.getContent()) .setgroup_id(customMessage.getMessageId()); // Key field for preventing collapsing MTPushPrivatesApi.showNotification(context, notificationMessage); }
              
              public void showNotification(Context context, CustomMessage customMessage) {
    NotificationMessage notificationMessage = new NotificationMessage()
        .setMessageId(customMessage.getMessageId())
        .setNotificationId("Define this yourself, but make sure each notification is different")
        .setTitle(customMessage.getTitle())
        .setContent(customMessage.getContent())
        .setgroup_id(customMessage.getMessageId()); // Key field for preventing collapsing

    MTPushPrivatesApi.showNotification(context, notificationMessage);
}

            
This code block in the floating window

Advantage Comparison

Capability Notification Custom Message
Supported app status FCM: foreground only; EngageLab: foreground and background All scenarios (foreground/background)
Style flexibility Limited (system-dependent) Fully customizable
Channel dependency Requires specific channels (FCM, EngageLab) No restriction

3. Notes

  1. Channel compatibility

    • The group_id feature currently supports only FCM and EngageLab channels. Other channels are not supported at this time.
  2. Performance optimization

    • When sending messages frequently with independent group_id values, monitor notification bar cache pressure on the system side (recommended: ≤30 messages per device per hour).

4. Summary

  • Lightweight requirements: Prefer using group_id to control notification collapse logic, as it has a lower development cost.
  • Highly customized requirements: Choose the custom message solution to achieve fully controllable display across all scenarios through client-side code.
  • Hybrid strategy: Use custom messages for important notifications (such as payment confirmations), and use group_id management for regular notifications.

By choosing the appropriate solution, you can significantly improve the delivery rate of critical messages and enhance the user interaction experience.

Icon Solid Transparent White Qiyu
Contact Sales