Skip to content

How to display modal mirror push notification manually

Alexander Boldyrev edited this page Oct 30, 2024 · 1 revision

Supported on Android since version 4.4.0

Manual displaying of Mirror push notifications at a specific time and screen could be done for 2 different use cases in your application:

  1. including default MM SDK's behaviour (with or without MM SDK's notification builder)
  2. dismissing default MM SDK's Mirror push notification displaying on the first opened screen while using default MM SDK's notification builder

Case 1: Include default MM SDK's behaviour

Manually display modal Mirror push notification for MM SDK's Message object:

MobileInteractive.getInstance(context).displayInAppDialogFor(message);
expand to see Java code

MobileInteractive.getInstance(context).displayInAppDialogFor(message);

Case 2: Dismiss Mirror push notification displaying on the first opened screen

Full implementation can be checked in CustomInApp Example

a. Disable automatic modal Mirror push notification displaying. It can be done as described in Notification Settings

b. Register broadcast receiver at application level to get MODAL_IN_APP_NOTIFICATION_IS_READY_TO_DISPLAY Event and Message from it:

override fun onReceive(context: Context?, intent: Intent) {
    val message = Message.createFrom(intent.extras)
}
expand to see Java code

@Override
public void onReceive(Context context, Intent intent) {
    Message message = Message.createFrom(intent.getExtras());
}

c. Display modal Mirror push notification for message you received in previous step:

MobileInteractive.getInstance(context).displayInAppDialogFor(message);
expand to see Java code

MobileInteractive.getInstance(context).displayInAppDialogFor(message);
Clone this wiki locally