Skip to content
Menu

In-app messages

Triggers and delivery rules

Markdown version

The three in-app triggers, property filters and their operators, priority, the minimum interval, one message at a time, pending messages and re-eligibility.

A trigger is the moment on the device that can show an in-app message. When a trigger fires, the SDK looks through the messages it has synced, keeps the ones whose trigger matches and whose rules allow them to show, and offers the one with the highest priority.

Triggers

TriggerWire valueFires when
Session startsession_startA new session starts and the message sync for it has finished (or failed, in which case the messages already on the device are used).
Custom eventeventYour app calls track with the message's event name, and every property filter matches.
Push openpush_openThe user opens a Herald push notification and your app passes it to handleNotificationResponse (iOS) or handleNotificationIntent (Android).

Only track fires event triggers. screen, trackPurchase and attribute calls do not. Events tracked by other systems, such as your backend or a warehouse sync, never trigger an in-app message: the decision is made on the device.

swift
// Can trigger a message whose trigger is workout_completed with minutes > 20.
Herald.shared.track("workout_completed", properties: ["minutes": 32, "type": "strength"])

Property filters

An event trigger can carry filters on the event's properties. Every filter must match.

OperatorMatches when the property
eqEquals the value. Type matters: 32 does not equal "32". Numbers compare by value, so 32 equals 32.0.
neqDoes not equal the value
gt, gte, lt, lteIs a number greater than, at least, less than, or at most the value. A string never matches.
containsIs a string that contains the value (case-sensitive), or a list that has the value as an element
existsIs present. The filter's value is ignored.

A missing property fails every filter, exists included. A property sent as null counts as missing. So neq "free" does not match an event that has no plan property at all. If you need "anything but free, or unknown", send the property every time.

Which message wins

When several messages match one trigger:

  1. Messages that have expired are left out.
  2. Messages the user is not eligible for again yet are left out (see re-eligibility below).
  3. The highest priority wins. On a tie, the first in Herald's order wins, which is the newest.

Display rules

RuleDefaultDetail
One at a timeAlwaysA message never shows over another Herald message.
Minimum interval30 secondsMeasured from the moment the last message appeared. Configurable. showNext() skips it.
Foreground onlyAlwaysMessages show while the app is in the foreground. A trigger that fires in the background waits for the app to come forward.
Presenter neededAlwaysWithout a presenter (see the overview), a message waits on the device.
ExpiryPer messageAfter expiresAt, the message is never shown.

Change the minimum interval at configuration:

swift
Herald.configure(appKey: "YOUR_APP_KEY", endpoint: URL(string: "https://YOUR_HERALD_HOST")!) { options in
    options.inAppMinimumInterval = 60 // seconds
}

Re-eligibility

Each message says how often the same user may see it.

ModeWire valueBehavior
OnceonceShown at most once to this user on this device
After hoursafter_hours with hoursEligible again that many hours after it last appeared
  • The history is kept per user on each device: the signed-in user's history, or the anonymous history before sign-in.
  • It survives app restarts, reset() and user switches. If the same user signs in again, their history comes back.
  • wipeData() clears it.
  • A message counts as shown only once the presenter has it on screen. A message that never appeared (no presenter, the app went to the background) stays eligible.
  • History is per device. A user with two phones can see a once message on each.

Pending messages

A message that matches a trigger joins a pending list on the device. It is never dropped because it could not show at that moment. The same rules apply on iOS and Android.

SituationWhat happens
Nothing is on screen, the minimum interval has passed, the app is in the foreground and a presenter is setThe SDK asks your delegate, then shows the message
Another message is on screenThe message waits and is offered when that message closes
The minimum interval has not passedThe message waits and is offered when the interval runs out
No presenter, or no screen to draw onThe message waits and is offered again when the app comes to the foreground, when an activity resumes (Android), on the next trigger, when a message closes, when a presenter is set (iOS), and on showNext()
The delegate answers laterThe message stays pending and is offered again at those same moments; the delegate is asked again each time
The delegate answers dropThe message leaves the pending list. It stays eligible for its next trigger.
The message expires or stops being eligible while it waitsIt leaves the pending list

When several messages are pending, the highest priority shows first. On a tie, the one that has waited longest goes first. The pending list is saved on the device, so it survives an app restart.

Pending messages are cleared by reset(), a user switch and wipeData().

Edge cases

  • The first session after install. The session-start trigger runs after the first sync, so a message an agent sent before the user opened the app can show in that same session.
  • Offline. Triggers use the messages from the last successful sync. A message sent since then shows after the next sync.
  • An unknown trigger, operator or message type from a newer Herald version is skipped; the other messages still load.

See Herald decide live →