Package com.swrve.sdk.messaging
Class SwrveInAppCampaign
- java.lang.Object
-
- com.swrve.sdk.messaging.SwrveBaseCampaign
-
- com.swrve.sdk.messaging.SwrveInAppCampaign
-
public class SwrveInAppCampaign extends SwrveBaseCampaign
Swrve campaign containing an in-app message targeted to the current device and user id.
-
-
Field Summary
Fields Modifier and Type Field Description protected SwrveMessage
message
-
Fields inherited from class com.swrve.sdk.messaging.SwrveBaseCampaign
campaignDisplayer, campaignManager, DEFAULT_DELAY_FIRST_MESSAGE, DEFAULT_MAX_IMPRESSIONS, DEFAULT_MIN_DELAY_BETWEEN_MSGS, endDate, id, maxImpressions, messageCenter, messageCenterDetails, minDelayBetweenMessage, name, priority, saveableState, showMessagesAfterLaunch, startDate, subject, triggers
-
-
Constructor Summary
Constructors Constructor Description SwrveInAppCampaign(ISwrveCampaignManager campaignManager, SwrveCampaignDisplayer campaignDisplayer, org.json.JSONObject campaignData, java.util.Set<com.swrve.sdk.SwrveAssetsQueueItem> assetsQueue, java.util.Map<java.lang.String,java.lang.String> properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areAssetsReady(java.util.Set<java.lang.String> assetsOnDisk, java.util.Map<java.lang.String,java.lang.String> properties)
Determine if the assets for this campaign have been downloaded.protected SwrveMessage
createMessage(SwrveInAppCampaign swrveCampaign, org.json.JSONObject messageData, java.io.File cacheDir)
com.swrve.sdk.QaCampaignInfo.CAMPAIGN_TYPE
getCampaignType()
Used by QAUser to determine what kind of campaign we are reportingSwrveMessage
getMessage()
SwrveMessage
getMessageForEvent(java.lang.String event, java.util.Map<java.lang.String,java.lang.String> payload, java.util.Date now, java.util.Map<java.lang.Integer,com.swrve.sdk.QaCampaignInfo> qaCampaignInfoMap)
Search for a message related to the given trigger event at the given time.SwrveMessage
getMessageForEvent(java.lang.String event, java.util.Map<java.lang.String,java.lang.String> payload, java.util.Date now, java.util.Map<java.lang.Integer,com.swrve.sdk.QaCampaignInfo> qaCampaignInfoMap, java.util.Map<java.lang.String,java.lang.String> properties)
Search for a message related to the given trigger event at the given time.SwrveMessage
getMessageForId(int messageId)
Search for a message with the given message id.protected SwrveMessage
getNextMessage(java.util.Map<java.lang.Integer,com.swrve.sdk.QaCampaignInfo> qaCampaignInfoMap, java.util.Map<java.lang.String,java.lang.String> properties)
int
getVariantId()
void
messageDismissed()
Notify that a message was dismissed.void
messageWasShownToUser()
Notify that a message was shown to the user.protected void
setMessage(SwrveMessage message)
boolean
supportsOrientation(com.swrve.sdk.messaging.SwrveOrientation orientation)
-
Methods inherited from class com.swrve.sdk.messaging.SwrveBaseCampaign
getDownloadDate, getEndDate, getId, getImpressions, getMaxImpressions, getMessageCenterDetails, getName, getPriority, getSaveableState, getShowMessagesAfterLaunch, getStartDate, getStatus, getSubject, getTriggers, incrementImpressions, isActive, isMessageCenter, setImpressions, setMessageCenterDetails, setMessageMinDelayThrottle, setSaveableState, setStatus
-
-
-
-
Field Detail
-
message
protected SwrveMessage message
-
-
Constructor Detail
-
SwrveInAppCampaign
public SwrveInAppCampaign(ISwrveCampaignManager campaignManager, SwrveCampaignDisplayer campaignDisplayer, org.json.JSONObject campaignData, java.util.Set<com.swrve.sdk.SwrveAssetsQueueItem> assetsQueue, java.util.Map<java.lang.String,java.lang.String> properties) throws org.json.JSONException
- Throws:
org.json.JSONException
-
-
Method Detail
-
getMessage
public SwrveMessage getMessage()
- Returns:
- the campaign messages.
-
getVariantId
public int getVariantId()
-
setMessage
protected void setMessage(SwrveMessage message)
-
getMessageForEvent
public SwrveMessage getMessageForEvent(java.lang.String event, java.util.Map<java.lang.String,java.lang.String> payload, java.util.Date now, java.util.Map<java.lang.Integer,com.swrve.sdk.QaCampaignInfo> qaCampaignInfoMap)
Search for a message related to the given trigger event at the given time. This function will return null if too many messages were dismissed, the campaign start is in the future, the campaign end is in the past or the given event is not contained in the trigger set.- Parameters:
event
- trigger eventpayload
- payload to compare conditions againstnow
- device timeqaCampaignInfoMap
- will contain the reason the campaign showed or didn't show- Returns:
- SwrveMessage message setup to the given trigger or null otherwise.
-
getMessageForEvent
public SwrveMessage getMessageForEvent(java.lang.String event, java.util.Map<java.lang.String,java.lang.String> payload, java.util.Date now, java.util.Map<java.lang.Integer,com.swrve.sdk.QaCampaignInfo> qaCampaignInfoMap, java.util.Map<java.lang.String,java.lang.String> properties)
Search for a message related to the given trigger event at the given time. This function will return null if too many messages were dismissed, the campaign start is in the future, the campaign end is in the past or the given event is not contained in the trigger set.- Parameters:
event
- trigger eventpayload
- payload to compare conditions againstnow
- device timeqaCampaignInfoMap
- will contain the reason the campaign showed or didn't showproperties
- personalization properties which can be applied to the getMessageEvent- Returns:
- SwrveMessage message setup to the given trigger or null otherwise.
-
getMessageForId
public SwrveMessage getMessageForId(int messageId)
Search for a message with the given message id.- Parameters:
messageId
- message id to look for- Returns:
- SwrveMessage message with the given id. If not found returns null.
-
getNextMessage
protected SwrveMessage getNextMessage(java.util.Map<java.lang.Integer,com.swrve.sdk.QaCampaignInfo> qaCampaignInfoMap, java.util.Map<java.lang.String,java.lang.String> properties)
-
createMessage
protected SwrveMessage createMessage(SwrveInAppCampaign swrveCampaign, org.json.JSONObject messageData, java.io.File cacheDir) throws org.json.JSONException
- Throws:
org.json.JSONException
-
messageWasShownToUser
public void messageWasShownToUser()
Notify that a message was shown to the user.- Overrides:
messageWasShownToUser
in classSwrveBaseCampaign
-
supportsOrientation
public boolean supportsOrientation(com.swrve.sdk.messaging.SwrveOrientation orientation)
- Specified by:
supportsOrientation
in classSwrveBaseCampaign
-
getCampaignType
public com.swrve.sdk.QaCampaignInfo.CAMPAIGN_TYPE getCampaignType()
Description copied from class:SwrveBaseCampaign
Used by QAUser to determine what kind of campaign we are reporting- Specified by:
getCampaignType
in classSwrveBaseCampaign
- Returns:
- CAMPAIGN_TYPE enum
-
messageDismissed
public void messageDismissed()
Notify that a message was dismissed.
-
areAssetsReady
public boolean areAssetsReady(java.util.Set<java.lang.String> assetsOnDisk, java.util.Map<java.lang.String,java.lang.String> properties)
Description copied from class:SwrveBaseCampaign
Determine if the assets for this campaign have been downloaded.- Specified by:
areAssetsReady
in classSwrveBaseCampaign
- Parameters:
assetsOnDisk
- All assets that are already downloaded.properties
- String map of personalized properties.- Returns:
- if the assets are ready
-
-