In-app messaging

In-app messages are toaster-style, foreground-only messages that your app displays when users open it. They do not require OS-level notification permission, so deliverability is close to 100% of your app install base. This message type is ideal for highly contextual, low-urgency communication.

The SDK renders the in-app UI itself. Your app does not wire up a view. The SDK exposes lifecycle callbacks so you can react when a message appears, is clicked, or is dismissed.

Note: In-app messages are a different surface from push notifications. Push notifications are delivered by the OS while the app is in the background; in-app messages are rendered by the SDK while the app is in the foreground. See Push Notifications for the push surface.

On this page

How it works

In-app messages are evaluated against your ZMP campaigns as the app moves to the foreground. When a message qualifies for the current user, the native SDK renders it on top of your UI — your app does not build the view. This is why in-app messages are a foreground-only surface and do not require OS notification permission.

You configure the campaign, its audience, and its triggers in ZMP; the SDK handles fetching and display. For the campaign builder walkthrough, see User Guide: In-App Messaging.

Start and stop in-app messaging

In-app messaging is enabled by default. To stop displaying in-app messages:

ZetaClient.inapp.stop();

To restart:

ZetaClient.inapp.start();

Note: The SDK does not persist the stop state; your app must manage this state. By default, the SDK starts displaying in-app messages on every launch.

Status check

Query whether in-app messaging is currently active:

ZetaClient.inapp.getStatus((value) => {
  console.log('In-app messaging active:', value);
});

In-app message delegate

The SDK provides lifecycle event listeners for in-app messages. First, set up the event emitter and listener, then register the delegate.

import ZetaClient, { ZetaCoreEvents } from 'zetakit_reactnative';
import { Platform, NativeEventEmitter, DeviceEventEmitter } from 'react-native';

const eventEmitter = Platform.select({
  ios: new NativeEventEmitter(ZetaClient.bridge),
  android: DeviceEventEmitter,
});

const inAppListener = eventEmitter?.addListener(
  ZetaCoreEvents.InAppMessageDelegate,
  (event) => {
    if (event.inAppMessageOnClicked != null) {
      // User clicked the in-app message, or submitted an email.
      // event.inAppMessageOnClicked contains message data
      // including deeplink, webLink, title, body, imageURls, additionalValues
    }

    if (event.inAppMessageWillAppear != null) {
      // In-app message is about to appear
    }

    if (event.inAppMessageDidAppear != null) {
      // In-app message has appeared
    }

    if (event.inAppMessageOnDimissed != null) {
      // User dismissed the in-app message
    }
  }
);

Important: Register the event listener before calling ZetaClient.inapp.setDelegate() to ensure the listener is active before the bridge starts emitting events.

After the listener is registered, activate the delegate:

ZetaClient.inapp.setDelegate();

Clean up: Retain the subscription returned by addListener and remove it when the owning component unmounts to avoid duplicate handlers and leaks:

// e.g. in a useEffect cleanup
return () => inAppListener?.remove();

Event types

Event keyWhen fired
inAppMessageWillAppearThe in-app message is about to be displayed.
inAppMessageDidAppearThe in-app message has been displayed.
inAppMessageOnClickedThe user clicked the in-app message or submitted an email form.
inAppMessageOnDimissedThe user dismissed the in-app message.

Each event object contains message metadata: title, body, messageUID, deeplink, webLink, imageURls, and additionalValues.

In-app email collection

In-app email collection prompts unknown users (users ZMP does not yet have an email for) to submit their email via an in-app form.

  • Email collection triggers only for unknown users in ZMP.
  • Known users who already have an email identifier in ZMP skip this flow entirely.

The submitted email is available in the inAppMessageOnClicked event data. Access it through the event's form data properties.

For ZMP campaign setup instructions, see User Guide: In-App Messaging.

Next

See also