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, Unity, and Web.
Accessing the API​
- iOS - Swift
- iOS - Objective-C
- Android - Kotlin
- Android - Java
- Unity
- Web
Once the Swrve instance is created in the AppDelegate as per the iOS Integration guide, retrieve a list all of the campaigns that the user qualifies for, and that are currently available, via let campaigns: [SwrveCampaign]:
let campaigns = SwrveSDK.messageCenterCampaigns()
The array contains a collection of SwrveCampaign objects. Each of these is an entry in the app's message center, and includes both in-app message and embedded campaigns.
To retrieve only the in-app message campaigns, use inAppMessageCenterCampaignsWith(_:withPersonalization:). To retrieve only the embedded campaigns, use embeddedMessageCenterCampaigns(personalization:):
let inAppCampaigns = SwrveSDK.inAppMessageCenterCampaignsWith(.portrait, withPersonalization: ["user_name": "Sam"])
let embeddedCampaigns = SwrveSDK.embeddedMessageCenterCampaigns(personalization: ["user_name": "Sam"])
To retrieve a single campaign by its ID, use messageCenterCampaign(withID:andPersonalization:), which returns nil if the campaign isn't currently eligible for the user:
if let campaign = SwrveSDK.messageCenterCampaign(withID: campaignID, andPersonalization: ["user_name": "Sam"]) {
SwrveSDK.showMessageCenter(campaign)
}
Once the Swrve instance is created in the AppDelegate as per the iOS Integration guide, retrieve a list all of the campaigns that the user qualifies for, and that are currently available, via NSArray* campaigns:
NSArray* campaigns = [SwrveSDK messageCenterCampaigns];
The array contains a collection of SwrveCampaign objects. Each of these is an entry in the app's message center, and includes both in-app message and embedded campaigns.
To retrieve only the in-app message campaigns, use inAppMessageCenterCampaignsWithOrientation:withPersonalization:. To retrieve only the embedded campaigns, use embeddedMessageCenterCampaignsWithPersonalization::
NSArray<SwrveInAppCampaign *>* inAppCampaigns = [SwrveSDK inAppMessageCenterCampaignsWithOrientation:UIInterfaceOrientationPortrait withPersonalization:@{@"user_name": @"Sam"}];
NSArray<SwrveEmbeddedMessage *>* embeddedCampaigns = [SwrveSDK embeddedMessageCenterCampaignsWithPersonalization:@{@"user_name": @"Sam"}];
To retrieve a single campaign by its ID, use messageCenterCampaignWithID:andPersonalization:, which returns nil if the campaign isn't currently eligible for the user:
SwrveCampaign* campaign = [SwrveSDK messageCenterCampaignWithID:campaignID andPersonalization:@{@"user_name": @"Sam"}];
if (campaign) {
[SwrveSDK showMessageCenterCampaign:campaign];
}
SwrveSDK.createInstance(this, <app_id>, "<api_key>")
The shared instance contains methods to list all of the campaigns that this user qualifies for, and that are available right now:
val campaigns: List<SwrveBaseCampaign> = SwrveSDK.getMessageCenterCampaigns()
The list contains a collection of SwrveBaseCampaign objects. Each of these is an entry in the app's message center, and includes both in-app message and embedded campaigns.
To resolve personalization in the campaign's message center details, pass a map of personalization properties. To restrict the list to a specific orientation, pass a SwrveOrientation value of Portrait, Landscape, or Both:
val campaigns = SwrveSDK.getMessageCenterCampaigns(mapOf("user_name" to "Sam"))
val portraitCampaigns = SwrveSDK.getMessageCenterCampaigns(SwrveOrientation.Portrait, mapOf("user_name" to "Sam"))
To retrieve a single campaign by its ID, use getMessageCenterCampaign, which returns null if the campaign isn't currently eligible for the user:
val campaign = SwrveSDK.getMessageCenterCampaign(campaignId, mapOf("user_name" to "Sam"))
if (campaign != null) {
SwrveSDK.showMessageCenterCampaign(campaign)
}
SwrveSDK.createInstance(this, <app_id>, "<api_key>");
The shared instance contains methods to list all of the campaigns that this user qualifies for, and that are available right now:
List<SwrveBaseCampaign> campaigns = SwrveSDK.getMessageCenterCampaigns();
The list contains a collection of SwrveBaseCampaign objects. Each of these is an entry in the app's message center, and includes both in-app message and embedded campaigns.
To resolve personalization in the campaign's message center details, pass a map of personalization properties. To restrict the list to a specific orientation, pass a SwrveOrientation value of Portrait, Landscape, or Both:
Map<String, String> properties = new HashMap<>();
properties.put("user_name", "Sam");
List<SwrveBaseCampaign> campaigns = SwrveSDK.getMessageCenterCampaigns(properties);
List<SwrveBaseCampaign> portraitCampaigns = SwrveSDK.getMessageCenterCampaigns(SwrveOrientation.Portrait, properties);
To retrieve a single campaign by its ID, use getMessageCenterCampaign, which returns null if the campaign isn't currently eligible for the user:
SwrveBaseCampaign campaign = SwrveSDK.getMessageCenterCampaign(campaignId, properties);
if (campaign != null) {
SwrveSDK.showMessageCenterCampaign(campaign);
}
The Swrve shared instance object contains a reference that you can use to list all of the campaigns that this user qualifies for, and that are available right now:
List<SwrveBaseCampaign> campaigns = SwrveComponent.Instance.SDK.GetMessageCenterCampaigns();
The array contains a collection of SwrveBaseCampaign objects. Each of these is an entry in the app's message center, and includes both in-app message and embedded campaigns.
Both parameters of GetMessageCenterCampaigns are optional. To resolve personalization in the campaign's message center details, pass a dictionary of personalization properties. To restrict the list to a specific orientation, pass a SwrveOrientation value; when you omit it, the SDK uses the current device orientation:
var properties = new Dictionary<string, string> { { "user_name", "Sam" } };
List<SwrveBaseCampaign> campaigns = SwrveComponent.Instance.SDK.GetMessageCenterCampaigns(null, properties);
List<SwrveBaseCampaign> portraitCampaigns = SwrveComponent.Instance.SDK.GetMessageCenterCampaigns(SwrveOrientation.Portrait, properties);
Once the Swrve instance is created as per the Web Integration guide, retrieve a list of all of the campaigns that the user qualifies for, and that are currently available:
const campaigns = SwrveSDK.getMessageCenterCampaigns();
The array contains a collection of ISwrveCampaign objects. Each of these is an entry in the app's message center, and includes both in-app message and embedded campaigns.
To retrieve only the in-app message campaigns, use getInAppMessageCenterCampaigns. To retrieve only the embedded campaigns, use getEmbeddedMessageCenterCampaigns:
const inAppCampaigns = SwrveSDK.getInAppMessageCenterCampaigns({ user_name: "Sam" });
const embeddedCampaigns = SwrveSDK.getEmbeddedMessageCenterCampaigns({ user_name: "Sam" });
To retrieve a single campaign by its ID, use getMessageCenterCampaign, which returns null if the campaign isn't currently eligible for the user:
const campaign = SwrveSDK.getMessageCenterCampaign(campaignID, { user_name: "Sam" });
if (campaign) {
SwrveSDK.showMessageCenterCampaign(campaign);
}
Note: getInAppMessageCenterCampaigns and getMessageCenterCampaign require Web SDK 3.0.0 or later. getEmbeddedMessageCenterCampaigns requires Web SDK 2.6.0 or later.
Checking for updates​
The Message Center list is a snapshot. To keep your UI in step with it, register a campaigns update listener and re-read the campaigns each time the listener is invoked. This API requires Swrve Android SDK 12.3.0 or later, or Swrve iOS SDK 10.11.0 or later.
The listener is invoked once after the SDK's initial content load attempt, whether or not anything changed, and again whenever content the SDK has fetched may have changed the campaigns. Invocations arrive in no guaranteed order, and the SDK does not compare the campaigns against what you last read, so let your own comparison decide whether to redraw.
Register the listener where you create the SDK instance. The first invocation is sent once and is never replayed, so a listener registered later may miss it.
- iOS - Swift
- iOS - Objective-C
- Android - Kotlin
- Android - Java
SwrveSDK.campaignsUpdateListener(self) // where self conforms to SwrveCampaignsUpdateDelegate
...
func campaignsUpdated() {
let campaigns = SwrveSDK.messageCenterCampaigns()
// redraw your message center
}
// add #import "SwrveCampaignsUpdateDelegate.h" to your imports
[SwrveSDK campaignsUpdateListener:self]; // where self conforms to protocol SwrveCampaignsUpdateDelegate
...
- (void)campaignsUpdated {
NSArray *campaigns = [SwrveSDK messageCenterCampaigns];
// redraw your message center
}
// Hold the listener in a field, because the SDK references it weakly.
private val campaignsListener = SwrveCampaignsUpdateListener {
val campaigns: List<SwrveBaseCampaign> = SwrveSDK.getMessageCenterCampaigns()
// redraw your message center
}
SwrveSDK.setCampaignsUpdateListener(campaignsListener)
// Hold the listener in a field, because the SDK references it weakly.
private SwrveCampaignsUpdateListener campaignsListener;
campaignsListener = () -> {
List<SwrveBaseCampaign> campaigns = SwrveSDK.getMessageCenterCampaigns();
// redraw your message center
};
SwrveSDK.setCampaignsUpdateListener(campaignsListener);
Both SDKs hold the listener with a weak reference, so keep your own strong reference to it for as long as you want updates. A listener the SDK is the only holder of is released, after which callbacks stop arriving and nothing is reported. On Android, pass null to stop updates.
The listener reports SDK-driven changes only. Your own calls to markMessageCenterCampaignAsSeen and removeMessageCenterCampaign change what the getters return without invoking it, so re-read the campaigns after those calls as well.
One of the invocations follows the SDK's attempt to download campaign assets, which is when new campaigns normally become readable. A campaign is not listed until its assets are on the device, and an individual download can fail, so the invocation is not a guarantee that every campaign is present.
Campaign properties​
Here are some examples of the campaign properties that are available in the Swrve Message Center API:
- iOS - Swift
- iOS - Objective-C
- Android - Kotlin
- Android - Java
- Unity
- Web
let campaigns = SwrveSDK.messageCenterCampaigns()
// Get campaign at some position in a table list
let campaign = campaigns[indexPath.row]
let id = campaign.ID
let name = campaign.name
let subject = campaign.messageCenterDetails?.subject
let dateStart = campaign.dateStart
let dateEnd = campaign.dateEnd
let priority = campaign.priority
let downloadDate = campaign.downloadDate()
// New message center details
let messageCenterSubject = campaign.messageCenterDetails?.subject
let messageCenterDescription = campaign.messageCenterDetails?.description
let accessibilityText = campaign.messageCenterDetails?.imageAccessibilityText
let messageCenterIconImage = campaign.messageCenterDetails?.image
NSArray *campaigns = [SwrveSDK messageCenterCampaigns];
// get campaign at some position in a table list
SwrveCampaign *campaign = [campaigns objectAtIndex:[indexPath row]];
NSUInteger ID = campaign.ID;
NSString *name = campaign.name;
NSString *subject = campaign.messageCenterDetails.subject;
NSDate *dateStart = campaign.dateStart;
NSDate *dateEnd = campaign.dateEnd;
NSNumber *priority = campaign.priority;
NSDate *downloadDate = [campaign downloadDate];
NSString *messageCenterSubject = campaign.messageCenterDetails.subject;
NSString *messageCenterDescription = campaign.messageCenterDetails.description;
NSString *accessibilityText = campaign.messageCenterDetails.imageAccessibilityText;
UIImage *messageCenterIconImage = campaign.messageCenterDetails.image;
val campaigns = SwrveSDK.getMessageCenterCampaigns()
// Get campaign at some position in a table list
val campaign = campaigns[adapter.getItem(getSelectedItemPosition())] as SwrveBaseCampaign
val id = campaign.id
val name = campaign.name
val dateStart = campaign.startDate
val dateEnd = campaign.endDate
val inAppCampaign = campaign as SwrveInAppCampaign
val priority = inAppCampaign.message.priority
val downloadDate = campaign.downloadDate
val messageCenterSubject = campaign.messageCenterDetails.subject
val messageCenterDescription = campaign.messageCenterDetails.description
val accessibilityText = campaign.messageCenterDetails.imageAccessibilityText
val messageCenterIconImage = campaign.messageCenterDetails.image
List campaigns = SwrveSDK.getMessageCenterCampaigns();
// get campaign at some position in a table list
SwrveBaseCampaign campaign = campaigns.get(adapter.getItem(getSelectedItemPosition()));
int ID = campaign.getId();
String name = campaign.getName();
Date dateStart = campaign.getStartDate();
Date dateEnd = campaign.getEndDate();
SwrveInAppCampaign inAppCampaign = (SwrveInAppCampaign)campaign;
int priority = inAppCampaign.getMessage().getPriority();
Date downloadDate = campaign.getDownloadDate();
String messageCenterSubject = campaign.getMessageCenterDetails().getSubject();
String messageCenterDescription = campaign.getMessageCenterDetails().getDescription();
String accessibilityText =campaign.getMessageCenterDetails().getImageAccessibilityText();
Bitmap messageCenterIconImage = campaign.getMessageCenterDetails().getImage();
// Example get message center campaign and properties.
List<SwrveBaseCampaign> campaigns = SwrveComponent.Instance.SDK.GetMessageCenterCampaigns();
SwrveBaseCampaign campaign = campaigns[0];
int ID = campaign.Id;
String name = campaign.Name;
String subject = campaign.Subject; // (this is deprecated, use new MessageCenterSubject)
Date dateStart = campaign.StartDate;
Date dateEnd = campaign.EndDate;
int priority = campaign.getPriority;
Date downloadDate = campaign.DownloadDate;
String messageCenterSubject = campaign.MessageCenterDetails.Subject;
String messageCenterDescription = campaign.MessageCenterDetails.Description;
String accessibilityText = campaign.MessageCenterDetails.ImageAccessibilityText;
Texture2d messageCenterIconImage = campaign.MessageCenterDetails.Image;
const campaigns = SwrveSDK.getMessageCenterCampaigns();
// Get campaign at some position in your rendered list
const campaign = campaigns[0];
const id = campaign.id;
const subject = campaign.subject;
const dateStart = campaign.start_date; // Epoch milliseconds
const dateEnd = campaign.end_date; // Epoch milliseconds
const isMessageCenter = campaign.message_center;
const minDelayBetweenMsgs = campaign.rules.min_delay_between_messages;
// In-app message campaigns carry a message, embedded campaigns carry an embedded_message
const content = campaign.message || campaign.embedded_message;
const name = content.name;
const priority = content.priority;
// Message center details
const messageCenterSubject = campaign.message_center_details?.subject;
const messageCenterDescription = campaign.message_center_details?.description;
const accessibilityText = campaign.message_center_details?.accessibility_text;
const imageAsset = campaign.message_center_details?.image_asset;
const dynamicImageUrl = campaign.message_center_details?.dynamic_image_url;
The following parameters are supported for in-app message and embedded campaign creation. Swrve's Message Center API returns these properties regardless of the SDK version:
- iOS, Android, and Unity
- Web
| Parameter | Description |
|---|---|
ID | A unique identifier. |
name | The name of the campaign, which defaults to Empty. |
state | The state of the campaign. |
minDelayBetweenMsgs | The minimum interval between different campaign messages. |
messageCenter | A flag that indicates a message center campaign is sent from the message center. |
subject | The message center campaign subject. This should match the campaign description. |
| Parameter | Description |
|---|---|
id | A unique identifier. |
message.name or embedded_message.name | The name of the campaign, which defaults to Empty. |
rules.min_delay_between_messages | The minimum interval between different campaign messages. |
message_center | A flag that indicates a message center campaign is sent from the message center. |
subject | The message center campaign subject. This should match the campaign description. |
The Web SDK does not expose campaign state. For more information, see Campaign status.
The Message Center API returns the below properties in the following SDKs: iOS SDK 8.1.0, Android SDK 10.2.0, Unity SDK 9.0.0, React Native SDK 4.0.0, and Web SDK 3.0.0. The values are configurable through the campaign Content page, on the Message center details tab.
- iOS, Android, and Unity
- Web
These parameters are exposed in the SwrveMessageCenterDetails object, and are currently only available for in-app message campaigns.
| Parameter | Description |
|---|---|
subject | The variant-specific subject of the campaign that corresponds to the Subject value set in the campaign's Content page. |
description | The description of the campaign that corresponds to the Description value set in the campaign's Content page. |
imageTypes: iOS: UIImageAndroid: BitmapUnity: Texture2d | The message center image that corresponds to the thumbnail image set in the campaign's content page. This property includes the image type data, ready to load into the image component. |
imageUrl | The personalized image URL. This is used for reference as the image is downloadable from the cache. |
imageSha | The imageSha is available if the thumbnail image has been uploaded into the dashboard. |
accessibilityText | The alt text value provided for the image. |
These parameters are exposed on the campaign's message_center_details object, and are available for both in-app message and embedded campaigns.
| Parameter | Description |
|---|---|
subject | The variant-specific subject of the campaign that corresponds to the Subject value set in the campaign's Content page. |
description | The description of the campaign that corresponds to the Description value set in the campaign's Content page. |
dynamic_image_url | The personalized image URL, with any personalization already resolved for the current user. |
image_asset | The asset name of the thumbnail image, available if the image has been uploaded into the dashboard. The Web SDK downloads the asset to the browser cache. |
accessibility_text | The alt text value provided for the image. |
There is no image equivalent, because the browser loads the thumbnail from a URL. Use dynamic_image_url where it is set, and fall back to image_asset otherwise.
Note: If a campaign's message center details contain personalization that cannot be resolved for the current user — for example, a realtime user property with no value and no fallback — the SDK excludes that campaign from the results, rather than returning it with unresolved content. Set a fallback value for any personalization you use in message center details so the campaign is still returned when the property is unavailable.
The following properties have been added to the existing campaign object.
- iOS, Android, and Unity
- Web
| Parameter | Description |
|---|---|
dateEnd | The end date of the campaign. |
priority | The priority of the campaign in relation to other message center campaigns. |
downloadDate | The date and time the campaign is downloaded to the user's device. If the campaign is downloaded to the device multiple times, this value reflects the first time the campaign was downloaded. |
name | The name of the campaign. Note: This property returned an empty value in previous versions of the Swrve SDKs. |
| Parameter | Description |
|---|---|
end_date | The end date of the campaign, as an Epoch timestamp in milliseconds. |
message.priority or embedded_message.priority | The priority of the campaign in relation to other message center campaigns. |
message.name or embedded_message.name | The name of the campaign. |
There is no downloadDate equivalent.
Parameter mapping to message center details​
The Message Center API parameters relate to the following options in the Message center details tab:
- iOS, Android, and Unity
- Web
| Message center details | Message Center API parameter |
|---|---|
| Subject | subject |
| Description | description |
| Thumbnail | image - The actual image, whether downloaded from the specified URL or uploaded to the dashboard. In the event the SDK cannot download the image from the URL, this represents the fallback image (if provided). |
| Upload file - If a thumbnail image was uploaded to the dashboard. | imageSha - If a URL was provided as the thumbnail image, then this represents the uploaded fallback image. |
| URL - If a thumbnail image was provided as a URL. | imageUrl |
| Alt text | accessibilityText |
| Message center details | Message Center API parameter |
|---|---|
| Subject | subject |
| Description | description |
| Upload file - If a thumbnail image was uploaded to the dashboard. | image_asset - If a URL was provided as the thumbnail image, then this represents the uploaded fallback image. |
| URL - If a thumbnail image was provided as a URL. | dynamic_image_url |
| Alt text | accessibility_text |
Campaign lifecycle examples​
The following examples illustrate how to use the Message Center API to manage the message lifecycle in your app, from displaying the campaign subject line and getting its status, to displaying a message or removing it from visibility.
Subject line​
To get the subject line of the campaign to display in the app's message center, use the following:
- iOS - Swift
- iOS - Objective-C
- Android - Kotlin
- Android - Java
- Unity
- Web
let item = campaigns[0]
let subject = item?.messageCenterDetails?.subject
SwrveCampaign *item = (SwrveCampaign*)[campaigns objectAtIndex:0];
NSString* subject = item.subject;
val item = campaigns[0]
val subject = item.messageCenterDetails?.subject
SwrveBaseCampaign item = campaigns.get(0);
String subject = item.getMessageCenterDetails().getSubject();
SwrveBaseCampaign item = campaigns[0];
string subject = item.Subject;
const item = campaigns[0];
const subject = item.message_center_details?.subject || item.subject;
Prefer the subject from message_center_details, which is variant-specific and resolves any personalization for the current user. The campaign-level subject is the campaign-wide value, and is null when no subject was set.
Campaign status​
To retrieve the status associated with each message center entry, use the following:
- iOS - Swift
- iOS - Objective-C
- Android - Kotlin
- Android - Java
- Unity
- Web
let status = item.state.status
Possible values are:
| Value | Description |
|---|---|
| unseen = 1 | Campaign hasn't been seen by the user. |
| seen = 2 | Campaign has been seen at least once by the user. |
| deleted = 3 | Campaign has been deleted and won't appear again in the inbox. |
SwrveCampaignStatus status = item.state.status;
Possible values are:
| Value | Description |
|---|---|
| SwrveCampaignStatusUnseen = 1 | Campaign hasn't been seen by the user. |
| SwrveCampaignStatusSeen = 2 | Campaign has been seen at least once by the user. |
| SwrveCampaignStatusDeleted = 3 | Campaign has been deleted and won't appear again in the inbox. |
val status: SwrveCampaignState.Status = item.getStatus()
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. |
SwrveCampaignState.Status status = item.getStatus();
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. |
SwrveCampaignState.Status status = item.Status;
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 Web SDK tracks campaign status internally and does not expose it on the campaign object. Instead, it applies the status for you:
| Status | Behavior |
|---|---|
| Unseen | The campaign's initial status. It is returned by the message center calls. |
| Seen | Set when the campaign is displayed, or when you call markMessageCenterCampaignAsSeen. The campaign is still returned by the message center calls. |
| Deleted | Set when you call removeMessageCenterCampaign. The campaign is no longer returned by any of the message center calls. |
To mark a campaign as seen without displaying it, for example when the user opens it in your own UI, use markMessageCenterCampaignAsSeen. It accepts either the campaign or its ID:
SwrveSDK.markMessageCenterCampaignAsSeen(item);
SwrveSDK.markMessageCenterCampaignAsSeen(campaignID);
Show campaign​
The SDK is responsible for rendering and reacting to the campaign, so this capability is provided by a single API call:
- iOS - Swift
- iOS - Objective-C
- Android - Kotlin
- Android - Java
- Unity
- Web
SwrveSDK.showMessageCenter(item)
[SwrveSDK showMessageCenterCampaign:item];
SwrveSDK.showMessageCenterCampaign(item)
SwrveSDK.showMessageCenterCampaign(item);
SwrveComponent.Instance.SDK.ShowMessageCenterCampaign(item);
SwrveSDK.showMessageCenterCampaign(item);
Personalization properties are optional, and the call returns a boolean indicating whether the campaign was handled:
const displayed = SwrveSDK.showMessageCenterCampaign(item, { user_name: "Sam" });
For an embedded campaign, the SDK invokes your embeddedCallback instead of rendering the content. For more information, see Message Center embedded campaigns.
Remove campaign​
Finally, to remove the campaign from visibility so it doesn't appear in the message center again, use the following:
- iOS - Swift
- iOS - Objective-C
- Android - Kotlin
- Android - Java
- Unity
- Web
SwrveSDK.removeMessageCenter(item)
[SwrveSDK removeMessageCenterCampaign:item];
SwrveSDK.removeMessageCenterCampaign(item)
SwrveSDK.removeMessageCenterCampaign(item);
SwrveComponent.Instance.SDK.RemoveMessageCenterCampaign(item);
SwrveSDK.removeMessageCenterCampaign(item);
As with markMessageCenterCampaignAsSeen, this also accepts a campaign ID:
SwrveSDK.removeMessageCenterCampaign(campaignID);
Note: removeMessageCenterCampaign requires Web SDK 2.5.0 or later.
General use case​
- iOS - Swift
- iOS - Objective-C
- Android - Kotlin
- Android - Java
- Unity
- Web
Use the let array: [SwrveCampaign] that the SwrveSDK.messageCenterCampaigns() call returns as a data provider to a table view, or custom view, for presentation in the app proper.
Use the NSArray that the [Swrve messageCenterCampaigns] call returns as a data provider to a table view, or custom view, for presentation in the app proper.
Use the list that the SwrveSDK.getMessageCenterCampaigns() call returns as the source of an ArrayAdapter<SwrveBaseCampaign> used in a ListView, or custom view, for presentation in the app proper.
Use the list that the SwrveSDK.getMessageCenterCampaigns() call returns as the source of an ArrayAdapter<SwrveBaseCampaign> used in a ListView, or custom view, for presentation in the app proper.
Use the list that the SDK returns to populate a ListLayout inside a Canvas and ScrollRect to display the items.
Use the ISwrveCampaign[] array that the SwrveSDK.getMessageCenterCampaigns() call returns as the data source for your own list, table, or carousel component.
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.