App inbox message basics

The App inbox functionality provides a platform-agnostic inbox for messages.
There is no default UI for the inbox, so a developer can integrate the inbox to fit your goals and branding.

1100

Many Leanplum users make their inbox messages lead to a full-screen message when tapped, with a Back button that leads users back to the inbox.

The inbox can store up to 300 messages for extended periods of time, allowing users to return to messages after the initial send. These messages stay in the inbox until your users delete them, or you can manually delete or ‘force-expire’ messages by deleting them from the Leanplum dashboard.

👍

App inbox messages don’t require push certificates, making them an effective way to reach users who have not subscribed for push notifications. Create an app inbox branch in your push campaigns so users who are not subscribed for push will still receive your message once they are inside your app.

Setup an app inbox

See the App Inbox developer docs for a full guide on how to integrate the inbox functionality in your app, as well as required SDK versions.

Once integrated, your developer can access the App Inbox data by calling the appropriate SDK method. Developers can set up the inbox to get messages, message counts, message attributes, and more.

Create an app inbox message

To create an app inbox Single message campaign, in the Create Campaign dialog select the App Inbox engagement channel.

1960

In Multi-message campaigns, you can also create an app inbox message by adding a new action to your campaign and selecting App Inbox as the channel.

2040

Next, you can edit the following settings:

1580

App inbox content

FieldUsage
TitleThe title of your message
SubtitleThe text below your message title
ImageAdd an image to your app inbox message
Advanced options (Data)Pass data with your message in the form of Text, Number, Bool, Group, File, or Color. (Dictionary)

Add an image to an app inbox message

To add an image:

  1. Click the Image field to choose an image. It is recommended to upload images directly to Leanplum. Alternatively, you can provide your own image URL.
1504
  1. Preview the message on your development device to verify the image displays as expected.

📘

To use app inbox images, your app must use a recent version of our SDK (Android 2.2.0+, iOS 2.0.0+).

Configure your app for app inbox images

  1. If you have not already, download and integrate the minimum required SDK: Android 2.2.0, iOS 2.0.0.
  2. We have exposed two new methods within the SDK: getImageFilePath and getImageUrl. Both of these methods can be used to return App Inbox images.
  3. By default, we will automatically download all App Inbox images and their corresponding images on getNewsfeed. We have added an optional flag: disableImagePrefetching. This can be used in conjunction with getImageUrl if you prefer to use a third-party library to manage image downloading.

Add an open action

You have the option of adding an Open Action, which is an app function that's delivered to users immediately after they open your app inbox message. For example, you can deep link users to the app store to leave you a review.

An Open Action can be a:

In the Content section, click Add Open Action and select which app function you want as your Open Action.

📘

Open Action in Multi-message Campaigns

In multi-message campaigns, the Open Action becomes the next action in your campaign chain.

By default, the Open Action will be delivered immediately, though you can add a delay if you want.

Delete an inbox message

Your users can manage their own inboxes by reading and deleting your messages. You can also delete messages on behalf of your users.

Deleting a campaign or action from Leanplum will remove the message from your users' app inboxes. Keep in mind, this permanently removes the message from your Leanplum history along with any of its analytics or A/B tests.

Set an expiration date for an app inbox message

You can also expire a message from your user's inboxes without deleting it from your Leanplum history.

  1. Open the app inbox message for which you want to set an expiration date. The expiration date may have already passed, or it may be for a future date.
  2. Under Advanced Options, click the + icon next to Data. Add a text key called expirationDate. As the value, type the message’s intended expiration date. Make sure this expiration date matches the date format you use in your code (for instance, the code sample below uses the date format YYYY-MM-DD).
1496
  1. Then, in your app’s code, make sure you have a change handler with callback onChanged for iOS or InboxChangedCallback for Android. You should have added this callback when completing your App Inbox setup.

This callback will remove all messages for which the expiration date has passed. Messages are retrieved asynchronously after the Leanplum.start() call, so the callback will be executed the next time app inbox messages are retrieved from the Leanplum server.

inbox.addChangedHandler(new InboxChangedCallback() {
 @Override
 public void inboxChanged() {
        LeanplumInbox inbox = Leanplum.getInbox();
        List<LeanplumInboxMessage> messageList = inbox.allMessages();
 for (LeanplumInboxMessage message: messageList) {
            JSONObject data = message.getData();
 try {
                String expDate = (String) data.get("expirationDate");
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
                Date date = dateFormat.parse(expDate);
                if (date.before(new Date())){
                    message.remove();
                }
            } catch (JSONException e) {
                e.printStackTrace();
            } catch (ParseException e) {
                e.printStackTrace();
            } catch (NullPointerException e) {
                e.printStackTrace();
            }
        }
    }
});
  1. Now you can run the new build of your app to deploy the callback. Messages whose expiration dates have passed will disappear from the app inbox. As always, we recommend testing this expiration callback on an internal message to ensure it’s working as expected.

📘

To set up app inbox, see our developer docs for App inbox.