Messaging (In-App/Landings)

In-App Campaigns allow you to trigger messages when users open your app or perform a specific action. This is great to communicate with users who have turned off push notifications or to show contextual messages while your users are browsing your app (e.g. special offers, update reminder, etc).

Mobile Landings allow you to easily introduce continuity between your app, and your pushes: A user opening a push will be greeted by a rich message related to what they opened, rather than just ending up on your app's main menu.

In-App formats

This documentation describes features common to both Mobile Landings and In-App Messaging.

Displaying In-App messages

Fully automatic mode

There is no code required to make In-App Messages work in automatic mode. Create some campaigns on your dashboard, and they will start coming up in your app.

Controlling the display using "Do Not Disturb mode"

You can also get more control on when messages are displayed without giving up on the automatic mode, by using the "Do Not Disturb" (DnD) mode.
It allows you to tell Batch to hold on a mobile landing for you, rather than display it without using the fully manual mode.
For example, if launching your app results in a splash screen or a fullscreen ad, you might find it undesirable to have Batch display something on top of it.

Turning on "Do Not Disturb" mode will make Batch enqueue the latest mobile landing, rather than display it.

Toggling DnD

Now, when you don't want Batch to automatically display, turn on Do Not Disturb:

batch.messaging.setDoNotDisturbEnabled(true)

Once you want to start showing landings automatically, call the method with false to turn it off.

Note: Disabling Do Not Disturb mode does NOT make Batch show the enqueued message

Displaying pending mobile landings

After coming back from DnD mode, you might want to show the enqueued message, as Batch will not do that automatically.

All you have to do, is ask Batch to show the message, if any:

batch.messaging.showPendingMessage()

Subscribing to lifecycle events

Batch will send events when a message (In-App or Mobile Landing) is displayed or closed. You can read the Tracking identifier set when creating the campaign, and do whatever you want with it (ex: adding your own analytics).

Here's how:

document.addEventListener('batchMessageShown', function(e) {
    var messageIdentifier = e.messageIdentifier;
    // Process the event as you wish. messageIdentifier can be undefined/null.
}, false);

document.addEventListener('batchMessageClosed', function(e) {
    var messageIdentifier = e.messageIdentifier;
}, false);

Note: As the tracking identifier is optional, messageIdentifier might not be present on the fired event.