Firing realtime events in iOS

In-app messages are triggered based on realtime in-app events. Real-time events can also be used for triggering comms like push notifications, email, SMS and inbox messages. This guide describes how to fire events from your iOS app.

Custom Events

If you want to send a message to your customers after custom events occur then you must fire these events with the hitEvent method. For example, if you want to track as an event whenever an user opens the settings page, you would do it as follows:

// Tagging opened_settings in code where settings is opened
XPush.hitEvent("opened_settings")
\\ Tagging opened_settings in code where settings is opened
[XPush hitEvent: @"opened_settings"];

The event opened_settings will then be available as a trigger option when creating an iOS push message.

Example of an iOS push campaign that will be triggered by the event 'opened_settings'.Example of an iOS push campaign that will be triggered by the event 'opened_settings'.

Example of an iOS push campaign that will be triggered by the event 'opened_settings'.

📘

An event is created in your project whenever you fire it for the first time from your app (as seen before), or you can also manually create it by navigating to Data Manager > Events > Create event.

Events Values

It's possible to pass a value with the event hit. It could be used for additional segmentation and personalisation of your messages.

To pass a string value with the event use:

XPush.hitEvent("test", withValue: "payload")
[XPush hitEvent: @"test" withValue: @"payload"];

To pass key-value pairs with the event use:

XPush.hitEvent("product_added_to_basket", withValues: [
    ""product_category": "Sports",
    "product_name": "Home Jersey"
])
[XPush hitEvent: @"product_added_to_basket" withValues: @{
  @"product_category": @"Sports",
  @"product_name": @"Home Jersey"
  }];

Session Start

There is a default event for tracking session starts or app open events. To enable In App messaging on app open call the following method before initialising Xtremepush in your App Delegate:

XPush.setInAppMessageEnabled(true)
[XPush setInAppMessageEnabled: YES];

From the Events tab you can then select the trigger Session Start to launch an in-app message.

Example of an In-app campaign triggered on Session Start.Example of an In-app campaign triggered on Session Start.

Example of an In-app campaign triggered on Session Start.

👍

Only in-app messages can be triggered on Session Start

Updated about a month ago


Firing realtime events in iOS


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.