Last modified February 11, 2016 by Shelly Wolfe

Swrve Message Center API

The Swrve Message Center is an API for campaigns that have been downloaded from Swrve and are intended to be accessible in a way where the app user is in control of the message lifecycle. This guide describes how the Message Center API is presented for iOS, Android and Unity.

Accessing the API

iOS

Once the Swrve instance is created in the AppDelegate as per the iOS Integration guide, you can retrieve a list all of the campaigns that the user qualifies for, and that are currently available, via:

The array contains a collection of SwrveBaseCampaign objects. Each of these is an entry in the app’s message center.

Android

The shared instance contains methods to list all of the _campaigns_ that this user qualifies for, and that are available right now:

The list contains a collection of SwrveBaseCampaign objects. Each of these is an entry in the app’s message center.

Unity

The Swrve shared instance object contains a reference that can be used to list all of the _campaigns_ that this user qualifies for, and that are available right now:

The array contains a collection of SwrveBaseCampaign objects. Each of these is an entry in the app’s message center.

To get the subject line of the campaign to display in the message center UI, use the following:

iOS

Android

Unity

To retrieve the status associated with each message center entry, use the following:

iOS

Possible values are:

Value Description
SWRVE_CAMPAIGN_STATUS_UNSEEN  = 0x1 Campaign hasn’t been seen by the user.
SWRVE_CAMPAIGN_STATUS_SEEN    = 0x2 Campaign has been seen at least once by the user.
SWRVE_CAMPAIGN_STATUS_DELETED = 0x3 Campaign has been deleted and won’t appear again in the inbox.

Android

Possible values are:

Value Description
SwrveCampaignState.Status.Unseen Campaign hasn’t been seen by the user.
SwrveCampaignState.Status.Seen Campaign has been seen at least once by the user.
SwrveCampaignState.Status.Deleted Campaign has been deleted and won’t appear again in the inbox.

Unity

Possible values are:

VALUE DESCRIPTION
SwrveCampaignState.Status.Unseen Campaign hasn’t been seen by the user.
SwrveCampaignState.Status.Seen Campaign has been seen at least once by the user.
SwrveCampaignState.Status.Deleted Campaign has been deleted and won’t appear again in the inbox.

The SDK is responsible for rendering and reacting to the conversation, so this capability is provided by a single API call:

iOS

Android

Unity

Finally, to remove the campaign from visibility so it doesn’t appear in the message center again, use the following:

iOS

Android

Unity


General Use Case

iOS

The NSArray* that is returned from the [[Swrve messaging] messageCenterCampaigns] call can be used as a data provider to a table view, or custom view, for presentation in the app proper.

Android

The list that is returned from the SwrveSDK.getMessageCenterCampaigns() call can be used as a the source of an ArrayAdapter<SwrveBaseCampaign> used in a ListView, or custom view, for presentation in the app proper.

Unity

The list that is returned from the SDK can be used to populate a ListLayout inside a Canvas and ScrollRect to display the items.

When the app user selects a campaign in the message center view, the app should call the showMessageCenterCampaign API call to present it to the user.

When the user deletes the entry in the message center view, then the app should call removeMessageCenterCampaign for the selected campaign.