Class SwrveInAppCampaign


  • public class SwrveInAppCampaign
    extends SwrveBaseCampaign
    Swrve campaign containing an in-app message targeted to the current device and user id.
    • 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 event
        payload - payload to compare conditions against
        now - device time
        qaCampaignInfoMap - 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 event
        payload - payload to compare conditions against
        now - device time
        qaCampaignInfoMap - will contain the reason the campaign showed or didn't show
        properties - 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
      • 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 class SwrveBaseCampaign
        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 class SwrveBaseCampaign
        Parameters:
        assetsOnDisk - All assets that are already downloaded.
        properties - String map of personalized properties.
        Returns:
        if the assets are ready