App inbox messages
App inbox messages are sent to an inbox that you create in your app. There is no default UI for the inbox, so a developer can code your inbox to fit your goals and branding.
The inbox can store up to 300 messages, allowing users to return to messages after the initial send. These messages stay in the inbox until you or your users delete them.
App inbox messages don’t require push certificates, making them an effective way to reach users who are not opted-in for push notifications. Some customers choose to duplicate all of their push notification campaigns as app inbox messages. That way, users who dismiss push notifications can still receive your message inside your app.
Integrate app inbox messages
This feature is supported on Leanplum Android SDK 1.2.17+ and Leanplum iOS SDK 1.3.8+. Once integrated, your developer can access the Inbox object by calling the appropriate Leanplum method. Developers can set up the inbox to get data, message counts, message attributes, and more.
For a full guide to integrating app inbox, see our developer docs for iOS and Android.
Create an app inbox message
To create an app inbox message, create a new message and select App Inbox Message as the message type.
Next, you can edit the following settings in the Messager Composer:
Title | The title of your message |
Subtitle | The text below your message title |
Image | Add an image to your app inbox message. (See below for details.) |
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
Personalize and enhance your app inbox messages to create more engaging experiences for your users.
- Create a new message and select App Inbox Message as the message type.
- Specify your Targets.
- Click the Image field to choose an image. Upload an image. If possible, we recommend uploading images directly to Leanplum. Alternatively, you can provide your own image URL.
- Preview the message on your development device to verify the image displays as expected.
- Click Start to send the message.
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
- If you have not already, download and integrate the minimum required SDK: Android 2.2.0, iOS 2.0.0.
- We have exposed two new methods within the SDK:
getImageFilePath
andgetImageUrl
. Both of these methods can be used to return App Inbox images. - 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 withgetImageUrl
if you prefer to use a third party library to manage image downloading.
Delete an app inbox message
Your users can manage their own inboxes by reading and deleting your messages. However, you can also delete messages on behalf of your users.
Deleting a message from your Leanplum dashboard will remove the message from your users' app inboxes. To delete a message from Leanplum, open the Message Composer and select Delete from the More Options menu in the upper right. Keep in mind, this will permanently remove 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.
- 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.
- Click Show All to expand the editing menu.
- 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).
- Then, in your app’s code, make sure you have a change handler with callback
onChanged
for iOS orInboxChangedCallback
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();
}
}
}
});
- 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.
Updated over 3 years ago