iOS In-App Message


Messaging and Mobile A/B Testing Deprecation

Messaging and mobile A/B testing are not available for purchase and will be deprecated from the product on January 1st, 2022. Read more information on the Mixpanel blog.

The Mixpanel iOS library will automatically check for a message when you identify the current user on your site. If a message is available for the current user that they haven't already seen, it will be displayed immediately in an overlay view.

Controlling When to Show an In-App Message

You may not want the messages to show immediately when your app loads. If, for example, you have a game and would like to show a message when a user accomplishes a goal, you need to turn off the automatic showing of messages by setting showNotificationOnActive to NO and call showNotificationWithID: at the appropriate point in your app.

// In application:didFinishLaunchingWithOptions:
Mixpanel *mixpanel = [Mixpanel sharedInstanceWithToken:
// Turn this off so the message doesn't pop up automatically.
mixpanel.showNotificationOnActive = NO;

- (void)playerFinishedLevel
    [mixpanel showNotificationWithID:INAPP_NOTIFICATION_ID];

If you don't want to specify the message ID, you can use showNotification instead, which will show the first available in-app message targeted at the identified user if there is one. Messages are never shown twice to the same user, so you don't have to check for yourself if the user already saw the message before calling showNotificationWithID:.

If you don't want mixpanel checking for new in-app messages when your app becomes active, you can turn it off by setting checkForNotificationsOnActive to NO. This means that in-app messages will not show automatically, and that the network request to retrieve the messages will occur only when you call showNotification or showNotificationWithID:.

Adjusting the Timing of Mini Messages

By default, a mini in-app message will display for 6 seconds before automatically dismissing itself. This number can be easily adjusted with the miniNotificationPresentationTime property.

// In application:didFinishLaunchingWithOptions:
Mixpanel *mixpanel = [Mixpanel sharedInstanceWithToken:

// Give users more time to see the message.
mixpanel.miniNotificationPresentationTime = 10.0;

Takeover (fullscreen) messages will only dismiss themselves in response to a user action and have no "duration".

Using Profile Properties

Just like emails, in-app messages will replace content wrapped in {{}}. For example, if you add a Location property to your user profiles, you can send messages like this:

Come and visit us at our {{ ${Location} }} office!

A user with a profile property Location: Asheville will get the following message:

Come and visit us at our Asheville office!

If some of your profiles have a value, but others don't, you can use a fallback value:

Come and visit us at our {{ ${Location} | fallback:"nearest" }} office!

Profiles without a Location property will receive this message:

Come and visit us at our nearest office!

Updated 3 months ago

iOS In-App Message

Suggested Edits are limited on API Reference Pages

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