Class SwrveBaseCampaign

    • Field Detail

      • DEFAULT_DELAY_FIRST_MESSAGE

        protected static int DEFAULT_DELAY_FIRST_MESSAGE
      • DEFAULT_MAX_IMPRESSIONS

        protected static int DEFAULT_MAX_IMPRESSIONS
      • DEFAULT_MIN_DELAY_BETWEEN_MSGS

        protected static int DEFAULT_MIN_DELAY_BETWEEN_MSGS
      • id

        protected int id
      • startDate

        protected java.util.Date startDate
      • endDate

        protected java.util.Date endDate
      • triggers

        protected java.util.List<Trigger> triggers
      • messageCenter

        protected boolean messageCenter
      • subject

        protected java.lang.String subject
      • priority

        protected int priority
      • maxImpressions

        protected int maxImpressions
      • minDelayBetweenMessage

        protected int minDelayBetweenMessage
      • showMessagesAfterLaunch

        protected java.util.Date showMessagesAfterLaunch
      • name

        protected java.lang.String name
    • Constructor Detail

      • SwrveBaseCampaign

        public SwrveBaseCampaign​(ISwrveCampaignManager campaignManager,
                                 SwrveCampaignDisplayer campaignDisplayer,
                                 org.json.JSONObject campaignData)
                          throws org.json.JSONException
        Throws:
        org.json.JSONException
    • Method Detail

      • getId

        public int getId()
        Returns:
        the campaign id.
      • isMessageCenter

        public boolean isMessageCenter()
        Used internally to identify campaigns that have been marked as MessageCenter campaigns on the dashboard.
        Returns:
        true if the campaign is an MessageCenter campaign.
      • getSubject

        @Deprecated
        public java.lang.String getSubject()
        Deprecated.
        Use SwrveMessageCenterDetails subject instead.
        This is populated by the Campaign description field from your Dashboard. Migrate to using the SwrveMessageCenterDetails subject;
        Returns:
        the name of the campaign.
      • isActive

        public boolean isActive​(java.util.Date date)
        Parameters:
        date - Current date
        Returns:
        true if the campaign is active at the given time.
      • getTriggers

        public java.util.List<Trigger> getTriggers()
        Returns:
        the triggers for this campaign.
      • getImpressions

        public int getImpressions()
        Returns:
        current impressions
      • setImpressions

        public void setImpressions​(int impressions)
      • getMaxImpressions

        public int getMaxImpressions()
        Returns:
        maximum impressions
      • getStartDate

        public java.util.Date getStartDate()
        Returns:
        the campaign start date.
      • getEndDate

        public java.util.Date getEndDate()
        Returns:
        the campaign end date.
      • incrementImpressions

        public void incrementImpressions()
        Increment impressions by one.
      • setMessageMinDelayThrottle

        protected void setMessageMinDelayThrottle()
        Ensures a new message cannot be shown until now + minDelayBetweenMessage
      • setStatus

        public void setStatus​(SwrveCampaignState.Status status)
        Used internally to set the status of the campaign.
        Parameters:
        status - new status of the campaign
      • getDownloadDate

        public java.util.Date getDownloadDate()
        Get the download date of the campaign.
        Returns:
        the download date of the campaign
      • messageWasShownToUser

        public void messageWasShownToUser()
        Used by sublcasses to inform that the campaign was displayed.
      • supportsOrientation

        public abstract boolean supportsOrientation​(com.swrve.sdk.messaging.SwrveOrientation orientation)
      • getCampaignType

        public abstract com.swrve.sdk.QaCampaignInfo.CAMPAIGN_TYPE getCampaignType()
        Used by QAUser to determine what kind of campaign we are reporting
        Returns:
        CAMPAIGN_TYPE enum
      • areAssetsReady

        public abstract 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.
        Parameters:
        assetsOnDisk - All assets that are already downloaded.
        properties - String map of personalized properties.
        Returns:
        if the assets are ready
      • getSaveableState

        public SwrveCampaignState getSaveableState()
        Obtain the serializable state of the campaign.
        Returns:
        the serializable state of the campaign.
      • setSaveableState

        public void setSaveableState​(SwrveCampaignState saveableState)
        Set the previous state of this campaign.
        Parameters:
        saveableState - The state to save
      • getShowMessagesAfterLaunch

        public java.util.Date getShowMessagesAfterLaunch()
      • getName

        public java.lang.String getName()
        Returns:
        the campaign name
      • getPriority

        public int getPriority()
        Returns:
        the priority of the campaign.