Package com.batch.android.localcampaigns
Class CampaignManager
- java.lang.Object
-
- com.batch.android.localcampaigns.CampaignManager
-
public class CampaignManager extends java.lang.ObjectHandles many local campaigns related features: - Remembers campaigns got from the backend - Saves/Restores campaigns from disk - Checks campaign condition satisfaction and triggers them - Automatically if in auto mode (if dev didn't ask Batch to delay campaigns) - Broadcasts an event/callback to the developer if in manual mode - TODO: update once decided
-
-
Constructor Summary
Constructors Constructor Description CampaignManager(LocalCampaignsSQLTracker viewTracker)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanareCampaignsLoaded()java.util.List<LocalCampaign>cleanCampaignList(java.util.List<LocalCampaign> campaignsToClean)Removes campaign that will never be ok, even in the future: - Expired campaigns - Campaigns that hit their capping - Campaigns that have a max api level too low (min api level doesn't not mean that it is busted forever)voidcloseViewTracker()voiddeleteAllCampaigns(android.content.Context context, boolean persist)Delete all campaignsvoiddeleteSavedCampaigns(android.content.Context context)voiddeleteSavedCampaignsAsync(android.content.Context context)java.util.List<LocalCampaign>getCampaignList()Returns a copy of the loaded campaignsLocalCampaigngetCampaignToDisplay(Signal signal)Get the higher priority campaign between all of those that are satisfied by the latest application event This is the campaign that you'll want to displayViewTrackergetViewTracker()booleanhasSavedCampaigns(android.content.Context context)protected booleanisCampaignDisplayable(LocalCampaign campaign)Checks if the campaign is displayable according to general conditions: - Capping checks - Current date over start date - Minimum API level - etc...protected booleanisCampaignOverCapping(LocalCampaign campaign, boolean ignoreMinInterval)Checks if a campaign is over its global capping.booleanisEventWatched(java.lang.String name)Checks if an event name will triggers at least one campaign, allowing for a fast pre-filter to check if it is worth checking other conditions for campaigns with an event triggersbooleanloadSavedCampaignResponse(android.content.Context context)voidopenViewTracker()static CampaignManagerprovide()voidsaveCampaigns(android.content.Context context, java.util.List<LocalCampaign> campaigns)voidsaveCampaignsAsync(android.content.Context context, java.util.List<LocalCampaign> campaigns)voidupdateCampaignList(java.util.List<LocalCampaign> updatedCampaignList)Update the currently stored campaign list.
-
-
-
Constructor Detail
-
CampaignManager
public CampaignManager(@NonNull LocalCampaignsSQLTracker viewTracker)
-
-
Method Detail
-
provide
public static CampaignManager provide()
-
updateCampaignList
public void updateCampaignList(@NonNull java.util.List<LocalCampaign> updatedCampaignList)Update the currently stored campaign list. Clear the previous list. Calling this will triggers campaigns that have seen their conditions met.- Parameters:
updatedCampaignList- Updated campaign list. Can't be null
-
deleteAllCampaigns
public void deleteAllCampaigns(android.content.Context context, boolean persist) throws PersistenceExceptionDelete all campaigns- Throws:
PersistenceException
-
getCampaignToDisplay
public LocalCampaign getCampaignToDisplay(@NonNull Signal signal)
Get the higher priority campaign between all of those that are satisfied by the latest application event This is the campaign that you'll want to display
-
isEventWatched
public boolean isEventWatched(@NonNull java.lang.String name)Checks if an event name will triggers at least one campaign, allowing for a fast pre-filter to check if it is worth checking other conditions for campaigns with an event triggers
-
getCampaignList
public java.util.List<LocalCampaign> getCampaignList()
Returns a copy of the loaded campaigns
-
cleanCampaignList
public java.util.List<LocalCampaign> cleanCampaignList(@NonNull java.util.List<LocalCampaign> campaignsToClean)
Removes campaign that will never be ok, even in the future: - Expired campaigns - Campaigns that hit their capping - Campaigns that have a max api level too low (min api level doesn't not mean that it is busted forever)
-
isCampaignOverCapping
protected boolean isCampaignOverCapping(LocalCampaign campaign, boolean ignoreMinInterval) throws ViewTrackerUnavailableException
Checks if a campaign is over its global capping.- Throws:
ViewTrackerUnavailableException
-
isCampaignDisplayable
protected boolean isCampaignDisplayable(LocalCampaign campaign)
Checks if the campaign is displayable according to general conditions: - Capping checks - Current date over start date - Minimum API level - etc...
-
saveCampaigns
public void saveCampaigns(@NonNull android.content.Context context, @NonNull java.util.List<LocalCampaign> campaigns)
-
saveCampaignsAsync
public void saveCampaignsAsync(@NonNull android.content.Context context, @NonNull java.util.List<LocalCampaign> campaigns)
-
deleteSavedCampaigns
public void deleteSavedCampaigns(@NonNull android.content.Context context)
-
deleteSavedCampaignsAsync
public void deleteSavedCampaignsAsync(@NonNull android.content.Context context)
-
hasSavedCampaigns
public boolean hasSavedCampaigns(android.content.Context context)
-
loadSavedCampaignResponse
public boolean loadSavedCampaignResponse(@NonNull android.content.Context context)
-
areCampaignsLoaded
public boolean areCampaignsLoaded()
-
openViewTracker
public void openViewTracker()
-
closeViewTracker
public void closeViewTracker()
-
getViewTracker
public ViewTracker getViewTracker()
-
-