In-app messages
Triggers and delivery rules
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
| Trigger | Wire value | Fires when |
|---|---|---|
| Session start | session_start | A 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 event | event | Your app calls track with the message's event name, and every property filter matches. |
| Push open | push_open | The 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.
// Can trigger a message whose trigger is workout_completed with minutes > 20.
Herald.shared.track("workout_completed", properties: ["minutes": 32, "type": "strength"])// Can trigger a message whose trigger is workout_completed with minutes > 20.
Herald.track("workout_completed", mapOf("minutes" to 32, "type" to "strength"))Property filters
An event trigger can carry filters on the event's properties. Every filter must match.
| Operator | Matches when the property |
|---|---|
eq | Equals the value. Type matters: 32 does not equal "32". Numbers compare by value, so 32 equals 32.0. |
neq | Does not equal the value |
gt, gte, lt, lte | Is a number greater than, at least, less than, or at most the value. A string never matches. |
contains | Is a string that contains the value (case-sensitive), or a list that has the value as an element |
exists | Is 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:
- Messages that have expired are left out.
- Messages the user is not eligible for again yet are left out (see re-eligibility below).
- The highest
prioritywins. On a tie, the first in Herald's order wins, which is the newest.
Display rules
| Rule | Default | Detail |
|---|---|---|
| One at a time | Always | A message never shows over another Herald message. |
| Minimum interval | 30 seconds | Measured from the moment the last message appeared. Configurable. showNext() skips it. |
| Foreground only | Always | Messages show while the app is in the foreground. A trigger that fires in the background waits for the app to come forward. |
| Presenter needed | Always | Without a presenter (see the overview), a message waits on the device. |
| Expiry | Per message | After expiresAt, the message is never shown. |
Change the minimum interval at configuration:
Herald.configure(appKey: "YOUR_APP_KEY", endpoint: URL(string: "https://YOUR_HERALD_HOST")!) { options in
options.inAppMinimumInterval = 60 // seconds
}Herald.configure(
this,
appKey = "YOUR_APP_KEY",
endpoint = "https://YOUR_HERALD_HOST",
options = HeraldOptions(inAppMinimumIntervalSeconds = 60),
)Re-eligibility
Each message says how often the same user may see it.
| Mode | Wire value | Behavior |
|---|---|---|
| Once | once | Shown at most once to this user on this device |
| After hours | after_hours with hours | Eligible 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
oncemessage 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.
| Situation | What happens |
|---|---|
| Nothing is on screen, the minimum interval has passed, the app is in the foreground and a presenter is set | The SDK asks your delegate, then shows the message |
| Another message is on screen | The message waits and is offered when that message closes |
| The minimum interval has not passed | The message waits and is offered when the interval runs out |
| No presenter, or no screen to draw on | The 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 later | The message stays pending and is offered again at those same moments; the delegate is asked again each time |
| The delegate answers drop | The message leaves the pending list. It stays eligible for its next trigger. |
| The message expires or stops being eligible while it waits | It 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.