public class Localytics
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Localytics.ImpressionType |
static class |
Localytics.InAppMessageDismissButtonLocation
Relative position of the dismiss button for in-app messages.
|
static class |
Localytics.ProfileScope
Possible profile scopes
|
Modifier and Type | Field and Description |
---|---|
static int |
LOCATION_PERMISSION_REQUEST_CODE |
Constructor and Description |
---|
Localytics() |
Modifier and Type | Method and Description |
---|---|
static void |
addProfileAttributesToSet(java.lang.String attributeName,
java.util.Date[] attributeValue)
Add a set of values to a customer profile attribute, defaulting to the app scope.
|
static void |
addProfileAttributesToSet(java.lang.String attributeName,
java.util.Date[] attributeValue,
Localytics.ProfileScope scope)
Add a set of values to a customer profile attribute.
|
static void |
addProfileAttributesToSet(java.lang.String attributeName,
long[] attributeValue)
Add a set of values to a customer profile attribute, defaulting to the app scope.
|
static void |
addProfileAttributesToSet(java.lang.String attributeName,
long[] attributeValue,
Localytics.ProfileScope scope)
Add a set of values to a customer profile attribute.
|
static void |
addProfileAttributesToSet(java.lang.String attributeName,
java.lang.String[] attributeValue)
Add a set of values to a customer profile attribute, defaulting to the app scope.
|
static void |
addProfileAttributesToSet(java.lang.String attributeName,
java.lang.String[] attributeValue,
Localytics.ProfileScope scope)
Add a set of values to a customer profile attribute.
|
static void |
appendAdidToInAppUrls(boolean enabled)
Set whether ADID parameter is added to In-App call to action URLs.
|
static void |
appendAdidToInboxUrls(boolean enabled)
Set whether ADID parameter is added to In-App call to action URLs.
|
static boolean |
areNotificationsDisabled()
Deprecated.
@see #setNotificationsDisabled(boolean)
|
static void |
autoIntegrate(android.app.Application application)
Integrates Localytics.
|
static void |
clearInAppMessageDisplayActivity()
Opposite from the setInAppMessageDisplayActivity, this method detaches any fragment manager from Localytics.
|
static void |
closeSession()
Closes the Localytics session.
|
static void |
decrementProfileAttribute(java.lang.String attributeName,
long decrementValue)
Decrement the value of a customer profile attribute by a specified amount, defaulting to the app scope.
|
static void |
decrementProfileAttribute(java.lang.String attributeName,
long decrementValue,
Localytics.ProfileScope scope)
Decrement the value of a customer profile attribute by a specified amount.
|
static void |
deleteInboxCampaign(InboxCampaign campaign)
Set an inbox campaign as deleted.
|
static void |
deleteProfileAttribute(java.lang.String attributeName)
Delete a customer profile attribute, defaulting to the app scope.
|
static void |
deleteProfileAttribute(java.lang.String attributeName,
Localytics.ProfileScope scope)
Delete a customer profile attribute.
|
static void |
dismissCurrentInAppMessage()
If an in-app message is currently displayed, dismiss it.
|
static boolean |
displayPushNotification(android.os.Bundle data)
Handle displaying a Localytics push notification.
|
static void |
enableLiveDeviceLogging()
Enter live device logging mode.
|
static java.util.List<InboxCampaign> |
getAllInboxCampaigns()
Get all Inbox campaigns.
|
static java.lang.String |
getAppKey()
Get the Localytics app key.
|
static java.lang.String |
getCustomDimension(int dimension)
Get the current value for a given dimension.
|
static java.lang.String |
getCustomerId()
Convenience method to get a customer's id.
|
static java.util.List<InboxCampaign> |
getDisplayableInboxCampaigns()
Get all Inbox campaigns that can be displayed.
|
static java.util.List<CircularRegion> |
getGeofencesToMonitor(double latitude,
double longitude)
Get a list of geofences to monitor for enter/exit events
|
static java.lang.String |
getIdentifier(java.lang.String key)
Get the identifier associated with a key.
|
static Localytics.InAppMessageDismissButtonLocation |
getInAppMessageDismissButtonLocation()
Get the relative position of the in-app message dismiss button.
|
static int |
getInboxCampaignsUnreadCount()
Get the count of unread inbox messages
|
static MarketingWebViewManager |
getInboxWebViewManager(java.util.concurrent.Callable<android.app.Activity> activityRetriever)
FOR LOCALYTICS WRAPPER USE ONLY.
|
static java.lang.String |
getInstallId()
Get the app's installation id.
|
static java.lang.String |
getLibraryVersion()
Get the Localytics library version.
|
static java.lang.String |
getLocalAuthenticationToken()
Get the app's local authentication token.
|
static java.lang.String |
getPushRegistrationId() |
static boolean |
handleFirebaseMessage(java.util.Map<java.lang.String,java.lang.String> messageData)
Conditionally handles the display of a Firebase remote notification if the message data is determined
to be a Localytics message.
|
static void |
handlePushNotificationOpened(android.content.Intent intent)
Handle opening a Localytics push notification.
|
static void |
handleTestMode(android.content.Intent intent)
Handle the intent for push test mode.
|
static void |
inboxListItemTapped(InboxCampaign campaign)
Tell the Localytics SDK that an Inbox campaign was tapped in the list view.
|
static void |
incrementProfileAttribute(java.lang.String attributeName,
long incrementValue)
Increment the value of a customer profile attribute by a specified amount, defaulting to the app scope.
|
static void |
incrementProfileAttribute(java.lang.String attributeName,
long incrementValue,
Localytics.ProfileScope scope)
Increment the value of a customer profile attribute by a specified amount.
|
static void |
integrate(android.content.Context context)
Integrates Localytics and initializes the Handlers.
|
static boolean |
isAdidAppendedToInAppUrls()
Returns whether the ADID parameter is added to In-App call to action URLs
|
static boolean |
isAdidAppendedToInboxUrls()
Returns whether the ADID parameter is added to Inbox call to action URLs
|
static boolean |
isLoggingEnabled()
Check whether the logging is enabled or disabled.
|
static boolean |
isOptedOut()
Get the opted in/out state.
|
static boolean |
isPrivacyOptedOut()
Get the privacy opted in/out state.
|
static boolean |
isTestModeEnabled()
Determine whether the test mode is enabled.
|
static void |
onActivityPause(android.app.Activity activity)
For alternative session management only
|
static void |
onActivityResume(android.app.Activity activity)
For alternative session management only
|
static void |
onNewIntent(android.app.Activity activity,
android.content.Intent intent)
Performs the same session management tasks as
onActivityResume(Activity, Intent)
but with the new Intent |
static void |
openSession()
Opens the Localytics session.
|
static void |
pauseDataUploading(boolean pause)
Halt the uploading of Analytics and Profiles data to the Localytics servers.
|
static void |
redirectLogsToDisk(boolean writeExternally,
android.content.Context context)
No production builds should call this method.
Enable/Disable log rerouting to a file on disk. |
static void |
refreshAllInboxCampaigns(InboxRefreshListener callback)
Refresh all Inbox campaigns from the Localytics server.
|
static void |
refreshInboxCampaigns(InboxRefreshListener callback)
Refresh all Inbox campaigns that can be displayed from the Localytics server.
|
static void |
registerPush()
Register app to receive push notifications from Localytics.
|
static void |
removeProfileAttributesFromSet(java.lang.String attributeName,
java.util.Date[] attributeValue)
Remove a set of values to a customer profile attribute, defaulting to the app scope.
|
static void |
removeProfileAttributesFromSet(java.lang.String attributeName,
java.util.Date[] attributeValue,
Localytics.ProfileScope scope)
Remove a set of values to a customer profile attribute.
|
static void |
removeProfileAttributesFromSet(java.lang.String attributeName,
long[] attributeValue)
Remove a set of values to a customer profile attribute, defaulting to the app scope.
|
static void |
removeProfileAttributesFromSet(java.lang.String attributeName,
long[] attributeValue,
Localytics.ProfileScope scope)
Remove a set of values to a customer profile attribute.
|
static void |
removeProfileAttributesFromSet(java.lang.String attributeName,
java.lang.String[] attributeValue)
Remove a set of values to a customer profile attribute, defaulting to the app scope.
|
static void |
removeProfileAttributesFromSet(java.lang.String attributeName,
java.lang.String[] attributeValue,
Localytics.ProfileScope scope)
Remove a set of values to a customer profile attribute.
|
static void |
setAnalyticsListener(AnalyticsListener listener)
Add a listener that will be notified of certain analytics callbacks:
AnalyticsListener.localyticsDidTagEvent(String, java.util.Map, long)
AnalyticsListener.localyticsSessionWillOpen(boolean, boolean, boolean)
AnalyticsListener.localyticsSessionDidOpen(boolean, boolean, boolean)
AnalyticsListener.localyticsSessionWillClose()
|
static void |
setCallToActionListener(CallToActionListener listener)
Add a listener that will be notified of certain callbacks:
CallToActionListener.localyticsShouldDeeplink(String, Campaign)
CallToActionListener.localyticsDidOptOut(boolean, Campaign)
CallToActionListener.localyticsDidPrivacyOptOut(boolean, Campaign)
Note, all methods invoked by this interface will be invoked on the main thread. |
static void |
setCustomDimension(int dimension,
java.lang.String value)
Sets the value of a custom dimension.
|
static void |
setCustomerEmail(java.lang.String email)
Convenience method to set a customer's email as both a profile attribute and
as a customer identifier.
|
static void |
setCustomerFirstName(java.lang.String firstName)
Convenience method to set a customer's first name as both a profile attribute and
as a customer identifier.
|
static void |
setCustomerFullName(java.lang.String fullName)
Convenience method to set a customer's full name as both a profile attribute and
as a customer identifier.
|
static void |
setCustomerId(java.lang.String customerId)
Convenience method to set a customer's id.
|
static void |
setCustomerIdWithPrivacyOptedOut(java.lang.String customerId,
boolean optedOut)
Convenience method to set a customer's id.
|
static void |
setCustomerLastName(java.lang.String lastName)
Convenience method to set a customer's last name as both a profile attribute and
as a customer identifier.
|
static void |
setIdentifier(java.lang.String key,
java.lang.String value)
Record your custom customer data.
|
static void |
setInAppMessageDismissButtonImage(android.content.res.Resources resources,
android.graphics.Bitmap image)
Set a bitmap object for user-defined dismiss button display.
|
static void |
setInAppMessageDismissButtonImage(android.content.res.Resources resources,
int id)
Set a image associated with a particular resource id for user-defined dismiss button display.
|
static void |
setInAppMessageDismissButtonLocation(Localytics.InAppMessageDismissButtonLocation buttonLocation)
Set the relative position of the in-app message dismiss button.
|
static void |
setInAppMessageDismissButtonVisibility(int visibility)
Set the visibility of the dismiss button.
|
static void |
setInAppMessageDisplayActivity(android.app.Activity activity)
Attach the current foreground activity Localytics.
|
static void |
setInboxCampaignRead(InboxCampaign campaign,
boolean read)
Set an inbox campaign as read.
|
static void |
setLocation(android.location.Location location)
Set a user's location.
|
static void |
setLocationListener(LocationListener listener)
Add a listener that will be notified of certain location callbacks:
LocationListener.localyticsDidUpdateLocation(Location) }
LocationListener.localyticsDidUpdateMonitoredGeofences(List, List)
|
static void |
setLocationMonitoringEnabled(boolean enabled)
Enable or disable location monitoring for geofence monitoring
|
static void |
setLocationMonitoringEnabled(boolean enabled,
boolean persist)
Enable or disable location monitoring for geofence monitoring and allow Localytics to
automatically reinitialize Location monitoring on App Launch
|
static void |
setLoggingEnabled(boolean enabled)
Enable/Disable logging.
|
static void |
setMessagingListener(MessagingListenerV2 listener)
Add a listener that will be notified of certain messaging callbacks:
MessagingListenerV2.localyticsDidDisplayInAppMessage()
MessagingListenerV2.localyticsWillDismissInAppMessage()
MessagingListenerV2.localyticsDidDismissInAppMessage()
MessagingListenerV2.localyticsShouldShowInAppMessage(InAppCampaign) }
MessagingListenerV2.localyticsShouldDelaySessionStartInAppMessages() }
MessagingListenerV2.localyticsWillDisplayInAppMessage(InAppCampaign, InAppConfiguration)
Note, all methods invoked by this interface will be invoked on the main thread. |
static void |
setNotificationsDisabled(boolean disable)
Deprecated.
This is deprecated in SDK 5.1 so that the standard dimension "notifications
enabled" can be directly tied to the OS setting. We recommend using a custom dimension to
continue supporting any app-level notification settings.
|
static void |
setOptedOut(boolean newOptOut)
Sets the Localytics opt-out state for this application.
|
static void |
setOption(java.lang.String key,
java.lang.Object value)
Customize the behavior of the SDK by setting a custom value for an option.
|
static void |
setOptions(java.util.Map<java.lang.String,java.lang.Object> options)
Customize the behavior of the SDK by setting custom values for various options.
|
static void |
setPrivacyOptedOut(boolean privacyOptedOut)
Sets the Localytics opt-out state for this application.
|
static void |
setProfileAttribute(java.lang.String attributeName,
java.util.Date attributeValue)
Set a customer profile attribute, defaulting to the app scope.
|
static void |
setProfileAttribute(java.lang.String attributeName,
java.util.Date[] attributeValue)
Set a customer profile attribute, defaulting to the app scope.
|
static void |
setProfileAttribute(java.lang.String attributeName,
java.util.Date[] attributeValue,
Localytics.ProfileScope scope)
Set a customer profile attribute.
|
static void |
setProfileAttribute(java.lang.String attributeName,
java.util.Date attributeValue,
Localytics.ProfileScope scope)
Set a customer profile attribute.
|
static void |
setProfileAttribute(java.lang.String attributeName,
long attributeValue)
Set a customer profile attribute, defaulting to the app scope.
|
static void |
setProfileAttribute(java.lang.String attributeName,
long[] attributeValue)
Set a customer profile attribute, defaulting to the app scope.
|
static void |
setProfileAttribute(java.lang.String attributeName,
long[] attributeValue,
Localytics.ProfileScope scope)
Set a customer profile attribute.
|
static void |
setProfileAttribute(java.lang.String attributeName,
long attributeValue,
Localytics.ProfileScope scope)
Set a customer profile attribute.
|
static void |
setProfileAttribute(java.lang.String attributeName,
java.lang.String attributeValue)
Set a customer profile attribute, defaulting to the app scope.
|
static void |
setProfileAttribute(java.lang.String attributeName,
java.lang.String[] attributeValue)
Set a customer profile attribute, defaulting to the app scope.
|
static void |
setProfileAttribute(java.lang.String attributeName,
java.lang.String[] attributeValue,
Localytics.ProfileScope scope)
Set a customer profile attribute.
|
static void |
setProfileAttribute(java.lang.String attributeName,
java.lang.String attributeValue,
Localytics.ProfileScope scope)
Set a customer profile attribute.
|
static void |
setPushRegistrationId(java.lang.String registrationId)
Set the push registration Id which was registered with FCM
|
static void |
setTestModeEnabled(boolean enabled)
Enable/Disable the test mode with the given flag.
|
static void |
tagAddedToCart(java.lang.String itemName,
java.lang.String itemId,
java.lang.String itemType,
java.lang.Long itemPrice,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag the addition of a single item to a cart (after the action has occurred)
|
static void |
tagCompletedCheckout(java.lang.Long totalPrice,
java.lang.Long itemCount,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag the conclusions of the checkout process (after the action has occurred)
|
static void |
tagContentRated(java.lang.String contentName,
java.lang.String contentId,
java.lang.String contentType,
java.lang.Long rating,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag the rating of content (after the action has occurred)
|
static void |
tagContentViewed(java.lang.String contentName,
java.lang.String contentId,
java.lang.String contentType,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag the viewing of content (after the action has occurred)
|
static void |
tagCustomerLoggedIn(Customer customer,
java.lang.String methodName,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag the logging in of a user (after the action has occurred)
|
static void |
tagCustomerLoggedOut(java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag the logging out of a user (after the action has occurred)
|
static void |
tagCustomerRegistered(Customer customer,
java.lang.String methodName,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag the registration of a user (after the action has occurred)
|
static void |
tagEvent(java.lang.String eventName)
Behaves identically to calling
tagEvent(eventName, null, 0) . |
static void |
tagEvent(java.lang.String eventName,
java.util.Map<java.lang.String,java.lang.String> attributes)
Behaves identically to calling
tagEvent(eventName, attributes, 0) . |
static void |
tagEvent(java.lang.String eventName,
java.util.Map<java.lang.String,java.lang.String> attributes,
long customerValueIncrease)
Within the currently open session, tags that
event occurred (with optionally included attributes). |
static void |
tagInAppImpression(InAppCampaign campaign,
Localytics.ImpressionType impressionType)
A standard event to tag an In-App impression
|
static void |
tagInAppImpression(InAppCampaign campaign,
java.lang.String customAction)
A standard event to tag an In-App impression.
|
static void |
tagInboxImpression(InboxCampaign campaign,
Localytics.ImpressionType impressionType)
A standard event to tag an Inbox impression
|
static void |
tagInboxImpression(InboxCampaign campaign,
java.lang.String customAction)
A standard event to tag an Inbox impression.
|
static void |
tagInvited(java.lang.String methodName,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag the invitation of a user (after the action has occured)
|
static void |
tagPlacesPushOpened(PlacesCampaign campaign)
A standard event to tag a Places Push Opened.
|
static void |
tagPlacesPushOpened(PlacesCampaign campaign,
java.lang.String action)
A standard event to tag a Places Push Opened.
|
static void |
tagPlacesPushReceived(PlacesCampaign campaign)
A standard event to tag a Places Push Received.
|
static void |
tagPurchased(java.lang.String itemName,
java.lang.String itemId,
java.lang.String itemType,
java.lang.Long itemPrice,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag a single item purchase event (after the action has occurred)
|
static void |
tagPushReceivedEvent(android.os.Bundle data)
Handle tagging the Localytics Push Received event.
|
static void |
tagPushReceivedEvent(java.util.Map<java.lang.String,java.lang.String> data)
Handle tagging the Localytics Push Received event.
|
static void |
tagPushToInboxImpression(InboxCampaign campaign)
A standard event to tag a Push to Inbox impression.
|
static void |
tagScreen(java.lang.String screen)
Note: This implementation will perform duplicate suppression on two identical screen events that occur in a row within a
single session.
|
static void |
tagSearched(java.lang.String queryText,
java.lang.String contentType,
java.lang.Long resultCount,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag a search event (after the action has occurred)
|
static void |
tagShared(java.lang.String contentName,
java.lang.String contentId,
java.lang.String contentType,
java.lang.String methodName,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag a share event (after the action has occurred)
|
static void |
tagStartedCheckout(java.lang.Long totalPrice,
java.lang.Long itemCount,
java.util.Map<java.lang.String,java.lang.String> attributes)
A standard event to tag the start of the checkout process (after the action has occurred)
|
static void |
triggerInAppMessage(java.lang.String triggerName)
Trigger an in-app message
|
static void |
triggerInAppMessage(java.lang.String triggerName,
java.util.Map<java.lang.String,java.lang.String> attributes)
Trigger an in-app message
|
static void |
triggerInAppMessagesForSessionStart()
Trigger campaigns as if a Session Start event had just occurred.
|
static void |
triggerPlacesNotification(long campaignId,
java.lang.String regionId)
Trigger a places notification for the given campaign id
|
static void |
triggerPlacesNotification(PlacesCampaign campaign)
Trigger a places notification for the given campaign
|
static void |
triggerRegion(Region region,
Region.Event event,
android.location.Location location)
Trigger a region with a certain event and location.
|
static void |
triggerRegions(java.util.List<Region> regions,
Region.Event event,
android.location.Location location)
Trigger a list of regions with a certain event and location.
|
static void |
upload()
Initiates an upload of all Localytics data.
|
public static final int LOCATION_PERMISSION_REQUEST_CODE
public static void integrate(@NonNull android.content.Context context)
context
- The context used to access resources on behalf of the app. Cannot be null.java.lang.IllegalArgumentException
- if context
is an Activity context or null, if
ll_app_key in localytics.xml is null or empty, or if PushReceiver is declared
in AndroidManifest.xml but PushTrackingActivity isn't declaredpublic static void autoIntegrate(@NonNull android.app.Application application)
application
- The app's application object. Cannot be null.java.lang.IllegalArgumentException
- if application is null, or if ll_app_key
in localytics.xml is null or empty.public static void upload()
public static void pauseDataUploading(boolean pause)
pause
- if set to true, all data uploading will be halted. If false, data uploading will resume as normal.public static void setOptedOut(boolean newOptOut)
newOptOut
- True if the user should be be opted out, halting further data collectionisOptedOut()
public static void setPrivacyOptedOut(boolean privacyOptedOut)
privacyOptedOut
- True if the user should be privacy opted out and have all his Localytics data deleted.setOptedOut(boolean)
,
isPrivacyOptedOut()
public static boolean isOptedOut()
setOptedOut(boolean)
public static boolean isPrivacyOptedOut()
setPrivacyOptedOut(boolean)
public static void openSession()
tagEvent(String)
, tagEvent(String, java.util.Map)
,
tagEvent(String, java.util.Map)
, or tagScreen(String)
are called.
If a new session is opened shortly--within a few seconds--after an earlier session is closed, Localytics will reconnect to
the previous session (effectively causing the previous close to be ignored). This ensures that as a user moves from
Activity to Activity in an app, that is considered a single session. When a session is reconnected, the
customDimensions
for the initial open are kept and dimensions for the second open are ignored.
If for any reason open is called more than once without an intervening call to closeSession()
, subsequent calls
to open will be ignored.
public static void closeSession()
openSession()
, close the session
when data collection is complete.
If close is called without open having ever been called, the close has no effect. Similarly, once a session is closed, subsequent calls to close will be ignored.
public static void tagEvent(java.lang.String eventName)
tagEvent(eventName, null, 0)
.eventName
- The name of the event which occurred. Cannot be null or empty string.java.lang.IllegalArgumentException
- if eventName
is null.java.lang.IllegalArgumentException
- if eventName
is empty.tagEvent(String, java.util.Map, long)
public static void tagEvent(java.lang.String eventName, java.util.Map<java.lang.String,java.lang.String> attributes)
tagEvent(eventName, attributes, 0)
.eventName
- The name of the event which occurred. Cannot be null or empty string.attributes
- The collection of attributes for this particular event. If this parameter is null or empty, then calling
this method has the same effect as calling tagEvent(String)
. This parameter may not contain null or
empty keys or values.java.lang.IllegalArgumentException
- if eventName
is null.java.lang.IllegalArgumentException
- if eventName
is empty.java.lang.IllegalArgumentException
- if attributes
contains null keys, empty keys, null values, or empty values.tagEvent(String, java.util.Map, long)
public static void tagEvent(java.lang.String eventName, java.util.Map<java.lang.String,java.lang.String> attributes, long customerValueIncrease)
Within the currently open session, tags that event
occurred (with optionally included attributes).
Attributes: Additional key/value pairs with data related to an event. For example, let's say your app displays a dialog with two buttons: OK and Cancel. When the user clicks on one of the buttons, the event might be "button clicked." The attribute key might be "button_label" and the value would either be "OK" or "Cancel" depending on which button was clicked.
Best PracticeseventName
- The name of the event which occurred. Cannot be null or empty string.attributes
- The collection of attributes for this particular event. If this parameter is null or empty, then no
attributes are recorded and the behavior with respect to attributes is like simply calling
tagEvent(String)
. This parameter may not contain null or empty keys or values.customerValueIncrease
- Added to customer lifetime value. Try to use lowest possible unit, such as cents for US currency.java.lang.IllegalArgumentException
- if eventName
is null.java.lang.IllegalArgumentException
- if eventName
is empty.java.lang.IllegalArgumentException
- if attributes
contains null keys, empty keys, null values, or empty values.public static void tagPurchased(@Nullable java.lang.String itemName, @Nullable java.lang.String itemId, @Nullable java.lang.String itemType, @Nullable java.lang.Long itemPrice, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
itemName
- The name of the item purchased (optional, can be null)itemId
- A unique identifier of the item being purchased, such as a SKU (optional, can be null)itemType
- The type of item (optional, can be null)itemPrice
- The price of the item (optional, can be null). Will be added to customer lifetime value. Try to use lowest possible unit, such as cents for US currency.attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagAddedToCart(@Nullable java.lang.String itemName, @Nullable java.lang.String itemId, @Nullable java.lang.String itemType, @Nullable java.lang.Long itemPrice, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
itemName
- The name of the item purchased (optional, can be null)itemId
- A unique identifier of the item being purchased, such as a SKU (optional, can be null)itemType
- The type of item (optional, can be null)itemPrice
- The price of the item (optional, can be null). Will NOT be added to customer lifetime value.attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagStartedCheckout(@Nullable java.lang.Long totalPrice, @Nullable java.lang.Long itemCount, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
totalPrice
- The total price of all the items in the cart (optional, can be null). Will NOT be added to customer lifetime value.itemCount
- Total count of items in the cart (optional, can be null)attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagCompletedCheckout(@Nullable java.lang.Long totalPrice, @Nullable java.lang.Long itemCount, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
totalPrice
- The total price of all the items in the cart (optional, can be null). Will be added to customer lifetime value. Try to use lowest possible unit, such as cents for US currency.itemCount
- Total count of items in the cart (optional, can be null)attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagContentViewed(@Nullable java.lang.String contentName, @Nullable java.lang.String contentId, @Nullable java.lang.String contentType, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
contentName
- The name of the content being viewed (such as article name) (optional, can be null)contentId
- A unique identifier of the content being viewed (optional, can be null)contentType
- The type of content (optional, can be null)attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagSearched(@Nullable java.lang.String queryText, @Nullable java.lang.String contentType, @Nullable java.lang.Long resultCount, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
queryText
- The query user for the search (optional, can be null)contentType
- The type of content (optional, can be null)resultCount
- The number of results returned by the query (optional, can be null)attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagShared(@Nullable java.lang.String contentName, @Nullable java.lang.String contentId, @Nullable java.lang.String contentType, @Nullable java.lang.String methodName, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
contentName
- The name of the content being viewed (such as article name) (optional, can be null)contentId
- A unique identifier of the content being viewed (optional, can be null)contentType
- The type of content (optional, can be null)methodName
- The method by which the content was shared such as Twitter, Facebook, Native (optional, can be null)attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagContentRated(@Nullable java.lang.String contentName, @Nullable java.lang.String contentId, @Nullable java.lang.String contentType, @Nullable java.lang.Long rating, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
contentName
- The name of the content being viewed (such as article name) (optional, can be null)contentId
- A unique identifier of the content being viewed (optional, can be null)contentType
- The type of content (optional, can be null)rating
- A rating of the content (optional, can be null)attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagCustomerRegistered(@Nullable Customer customer, @Nullable java.lang.String methodName, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
customer
- An object providing information about the customer that registered (optional, can be null)methodName
- The method by which the user was registered such as Twitter, Facebook, Native (optional, can be null)attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagCustomerLoggedIn(@Nullable Customer customer, @Nullable java.lang.String methodName, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
customer
- An object providing information about the customer that logged in (optional, can be null)methodName
- The method by which the user was logged in such as Twitter, Facebook, Native (optional, can be null)attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagCustomerLoggedOut(@Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagInvited(@Nullable java.lang.String methodName, @Nullable java.util.Map<java.lang.String,java.lang.String> attributes)
methodName
- The method by which the user was invited such as Twitter, Facebook, Native (optional, can be null)attributes
- Any additional attributes to attach to this event (optional, can be null)public static void tagInAppImpression(@NonNull InAppCampaign campaign, @NonNull Localytics.ImpressionType impressionType)
campaign
- The In-App campaign for which to tag an impressionimpressionType
- an enum of CLICK or DISMISSpublic static void tagInAppImpression(@NonNull InAppCampaign campaign, @NonNull java.lang.String customAction)
tagInAppImpression(InAppCampaign, ImpressionType)
Any String value passed in that is not equal to 'X' will result in a click on the dashboard.
If an empty String is passed in, a dismiss impression will be tagged.campaign
- The In-App campaign for which to tag an impressioncustomAction
- a string to tag the impression with.public static void tagInboxImpression(@NonNull InboxCampaign campaign, @NonNull Localytics.ImpressionType impressionType)
campaign
- The inbox campaign for which to tag an impressionimpressionType
- an enum of CLICK or DISMISSpublic static void tagInboxImpression(@NonNull InboxCampaign campaign, @NonNull java.lang.String customAction)
tagInboxImpression(InboxCampaign, ImpressionType)
Any String value passed in that is not equal to 'X' will result in a click on the dashboard.
If an empty String is passed in, a dismiss impression will be tagged.campaign
- The inbox campaign for which to tag an impressioncustomAction
- a string to tag the impression with.public static void tagPushToInboxImpression(@NonNull InboxCampaign campaign)
campaign
- The inbox campaign for which to tag an impressionpublic static void tagPlacesPushReceived(@NonNull PlacesCampaign campaign)
Standard integrations should not require this method. Rather it should only be used if standard places triggering is suppressed in favor of custom logic.
campaign
- The Places campaign for which to tag an eventpublic static void tagPlacesPushOpened(@NonNull PlacesCampaign campaign)
Standard integrations should not require this method. Rather it should only be used if standard places triggering is suppressed in favor of custom logic.
campaign
- The Places campaign for which to tag an eventpublic static void tagPlacesPushOpened(@NonNull PlacesCampaign campaign, @Nullable java.lang.String action)
Standard integrations should not require this method. Rather it should only be used if standard places triggering is suppressed in favor of custom logic.
campaign
- The Places campaign for which to tag an eventaction
- The title of the button that was pressed. This property will be passed
as the value of the 'Action' attribute ('Click' will be used if null).public static void triggerPlacesNotification(@NonNull PlacesCampaign campaign)
campaign
- The Places campaign for which to trigger a notificationpublic static void triggerPlacesNotification(long campaignId, @NonNull java.lang.String regionId)
campaignId
- The Places campaign id for which to trigger a notificationregionId
- The unique region id which triggered the Places Campaign.public static void tagScreen(java.lang.String screen)
screen
- Name of the screen that was entered. Cannot be null or the empty string.java.lang.IllegalArgumentException
- if screen
is null.java.lang.IllegalArgumentException
- if screen
is empty.public static void setCustomDimension(int dimension, java.lang.String value)
dimension
- A dimension between 0 and 9.value
- The value to set for the given dimension.java.lang.IllegalArgumentException
- if dimension
is not between 0 and 9.getCustomDimension(int)
public static java.lang.String getCustomDimension(int dimension)
dimension
- A dimension between 0 and 9.setCustomDimension(int, String)
public static void setAnalyticsListener(@Nullable AnalyticsListener listener)
listener
- The object that will receive the callbacks. Pass in null to remove an existing listener.public static void setProfileAttribute(java.lang.String attributeName, long attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void setProfileAttribute(java.lang.String attributeName, long attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void setProfileAttribute(java.lang.String attributeName, long[] attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute values (cannot be null).scope
- The scope of the attribute.public static void setProfileAttribute(java.lang.String attributeName, long[] attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void setProfileAttribute(java.lang.String attributeName, java.lang.String attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void setProfileAttribute(java.lang.String attributeName, java.lang.String attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void setProfileAttribute(java.lang.String attributeName, java.lang.String[] attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void setProfileAttribute(java.lang.String attributeName, java.lang.String[] attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void setProfileAttribute(java.lang.String attributeName, java.util.Date attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void setProfileAttribute(java.lang.String attributeName, java.util.Date attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void setProfileAttribute(java.lang.String attributeName, java.util.Date[] attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void setProfileAttribute(java.lang.String attributeName, java.util.Date[] attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void addProfileAttributesToSet(java.lang.String attributeName, long[] attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void addProfileAttributesToSet(java.lang.String attributeName, long[] attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void addProfileAttributesToSet(java.lang.String attributeName, java.lang.String[] attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void addProfileAttributesToSet(java.lang.String attributeName, java.lang.String[] attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void addProfileAttributesToSet(java.lang.String attributeName, java.util.Date[] attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void addProfileAttributesToSet(java.lang.String attributeName, java.util.Date[] attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void removeProfileAttributesFromSet(java.lang.String attributeName, long[] attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void removeProfileAttributesFromSet(java.lang.String attributeName, long[] attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void removeProfileAttributesFromSet(java.lang.String attributeName, java.lang.String[] attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void removeProfileAttributesFromSet(java.lang.String attributeName, java.lang.String[] attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void removeProfileAttributesFromSet(java.lang.String attributeName, java.util.Date[] attributeValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).scope
- The scope of the attribute.public static void removeProfileAttributesFromSet(java.lang.String attributeName, java.util.Date[] attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value (cannot be null).public static void incrementProfileAttribute(java.lang.String attributeName, long incrementValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.incrementValue
- The amount by which to increment the value.scope
- The scope of the attribute.public static void incrementProfileAttribute(java.lang.String attributeName, long incrementValue)
attributeName
- The attribute name.incrementValue
- The amount by which to increment the value.public static void decrementProfileAttribute(java.lang.String attributeName, long decrementValue, Localytics.ProfileScope scope)
attributeName
- The attribute name.decrementValue
- The amount by which to decrement the value.scope
- The scope of the attribute.public static void decrementProfileAttribute(java.lang.String attributeName, long decrementValue)
attributeName
- The attribute name.decrementValue
- The amount by which to decrement the value.public static void deleteProfileAttribute(java.lang.String attributeName, Localytics.ProfileScope scope)
attributeName
- The attribute name.scope
- The scope of the attribute.public static void deleteProfileAttribute(java.lang.String attributeName)
attributeName
- The attribute name.public static void setCustomerEmail(java.lang.String email)
email
- Customer's emailpublic static void setCustomerFirstName(java.lang.String firstName)
firstName
- Customer's first namepublic static void setCustomerLastName(java.lang.String lastName)
lastName
- Customer's last namepublic static void setCustomerFullName(java.lang.String fullName)
fullName
- Customer's full namepublic static void setInAppMessageDisplayActivity(android.app.Activity activity)
activity
- The foreground activity, must not be null.java.lang.IllegalArgumentException
- if activity
is null.clearInAppMessageDisplayActivity()
public static void clearInAppMessageDisplayActivity()
public static void triggerInAppMessage(java.lang.String triggerName)
triggerName
- The name of the in-app message triggerpublic static void triggerInAppMessagesForSessionStart()
This is useful for integrations that want to delay presentation
of startup campaigns due to some startup state, such as a splash screen.
In order to delay the triggering, implement
MessagingListenerV2
and respond appropriately to
MessagingListenerV2.localyticsShouldDelaySessionStartInAppMessages()
.
Finally, once the start up state has cleared, call this method to trigger in-app
campaigns as if a session had just been started.
public static void triggerInAppMessage(java.lang.String triggerName, java.util.Map<java.lang.String,java.lang.String> attributes)
triggerName
- The name of the in-app message triggerattributes
- The attributes associated with the in-app triggering eventpublic static void dismissCurrentInAppMessage()
public static void registerPush()
java.lang.UnsupportedOperationException
- if com.google.firebase:firebase-messaging is excluded from the app.public static java.lang.String getPushRegistrationId()
public static void setPushRegistrationId(java.lang.String registrationId)
registrationId
- The FCM registration Id@Deprecated public static void setNotificationsDisabled(boolean disable)
registerPush()
has been called.
This is typically used for app-level notification settings, since for Android 4.4+ this is
populated with the OS-level settings from the support library.disable
- Boolean flag to enable or disable push notifications. Note that true value
disables push while a false value enables it.areNotificationsDisabled()
@Deprecated public static boolean areNotificationsDisabled()
setNotificationsDisabled(boolean)
.public static void handlePushNotificationOpened(android.content.Intent intent)
intent
- The Intent of the push notification.public static boolean handleFirebaseMessage(java.util.Map<java.lang.String,java.lang.String> messageData)
messageData
- The data map derived from com.google.firebase.messaging.RemoteMessage.getData()public static void tagPushReceivedEvent(android.os.Bundle data)
FirebaseTokenService
.
Pass the RemoteMessage.getData()
delivered to FirebaseMessagingService.onMessageReceived(RemoteMessage)
to this method to tag the 'Localytics Push Received' event.data
- The Bundle of the push notification.public static void tagPushReceivedEvent(java.util.Map<java.lang.String,java.lang.String> data)
FirebaseService
or
handleFirebaseMessage(Map)
method).
Pass the RemoteMessage.getData()
delivered to
FirebaseMessagingService.onMessageReceived(com.google.firebase.messaging.RemoteMessage)
to this method to tag the 'Localytics Push Received' event.data
- The data of the push notification retrieved by calling
RemoteMessage.getData()
.public static boolean displayPushNotification(android.os.Bundle data)
data
- The Bundle of the push notification.public static void handleTestMode(android.content.Intent intent)
intent
- The same intent object from activity's getIntent method.
The intent contains params for push test mode. Cannot be null.java.lang.IllegalArgumentException
- if intent
is null.public static void setTestModeEnabled(boolean enabled)
enabled
- Flag to indicate whether to enable the test mode or not.isTestModeEnabled()
public static boolean isTestModeEnabled()
setTestModeEnabled(boolean)
public static void enableLiveDeviceLogging()
public static void setInAppMessageDismissButtonImage(android.content.res.Resources resources, @DrawableRes int id)
resources
- The Resources instance for your application's package.id
- The image resource id for the close button appearance.public static void setInAppMessageDismissButtonImage(android.content.res.Resources resources, android.graphics.Bitmap image)
resources
- The Resources instance for your application's package.image
- The bitmap object for the close button appearance.public static void setInAppMessageDismissButtonVisibility(int visibility)
visibility
- The visibility state of the dismiss buttonView.setVisibility(int)
public static void setMessagingListener(@Nullable MessagingListenerV2 listener)
MessagingListenerV2.localyticsDidDisplayInAppMessage()
MessagingListenerV2.localyticsWillDismissInAppMessage()
MessagingListenerV2.localyticsDidDismissInAppMessage()
MessagingListenerV2.localyticsShouldShowInAppMessage(InAppCampaign)
}MessagingListenerV2.localyticsShouldDelaySessionStartInAppMessages()
}MessagingListenerV2.localyticsWillDisplayInAppMessage(InAppCampaign, InAppConfiguration)
listener
- The object that will receive the callbacks. Pass in null to remove an existing listener.public static void setCallToActionListener(@Nullable CallToActionListener listener)
listener
- The object that will receive the callbacks. Pass in null to remove an existing listener.public static void appendAdidToInAppUrls(boolean enabled)
enabled
- Set to true to enable the ADID parameter or false to disable itpublic static boolean isAdidAppendedToInAppUrls()
public static void appendAdidToInboxUrls(boolean enabled)
enabled
- Set to true to enable the ADID parameter or false to disable itpublic static boolean isAdidAppendedToInboxUrls()
public static java.util.List<InboxCampaign> getDisplayableInboxCampaigns()
public static java.util.List<InboxCampaign> getAllInboxCampaigns()
public static void refreshInboxCampaigns(InboxRefreshListener callback)
callback
- Interface callback for when refresh is completeInboxRefreshListener
public static void refreshAllInboxCampaigns(InboxRefreshListener callback)
callback
- Interface callback for when refresh is completeInboxRefreshListener
public static void setInboxCampaignRead(InboxCampaign campaign, boolean read)
campaign
- the campaign object of the Inbox campaign.read
- true to mark the campaign as read, false to mark it as unreadInboxCampaign.isRead()
,
InboxListAdapter
public static void deleteInboxCampaign(InboxCampaign campaign)
campaign
- the campaign object of the Inbox campaign.InboxListAdapter
public static int getInboxCampaignsUnreadCount()
public static void inboxListItemTapped(InboxCampaign campaign)
campaign
- The Inbox campaign that was tapped in the list view.public static MarketingWebViewManager getInboxWebViewManager(java.util.concurrent.Callable<android.app.Activity> activityRetriever)
activityRetriever
- A callable that will return the current Activity.public static void setLocationMonitoringEnabled(boolean enabled)
enabled
- Flag to indicate whether the monitoring should be enabled or disabled.public static void setLocationMonitoringEnabled(boolean enabled, boolean persist)
enabled
- Flag to indicate whether the monitoring should be enabled or disabled.persist
- Flag to indicate whether the monitoring should be enabled or disabled automatically on App Launch.@NonNull public static java.util.List<CircularRegion> getGeofencesToMonitor(double latitude, double longitude)
latitude
- The user's current location latitude valuelongitude
- The user's current location longitude valuepublic static void triggerRegion(@NonNull Region region, @NonNull Region.Event event, @Nullable android.location.Location location)
region
- The region that was triggeredevent
- The event that triggered the region (@see Region.Event
.location
- The location that triggered the regionspublic static void triggerRegions(@NonNull java.util.List<Region> regions, @NonNull Region.Event event, @Nullable android.location.Location location)
regions
- A list of regions that were triggeredevent
- The event that triggered the region (@see Region.Event
.location
- The location that triggered the regionspublic static void setLocationListener(@Nullable LocationListener listener)
listener
- The object that will receive the callbacks. Pass in null to remove an existing listener.public static void setIdentifier(java.lang.String key, java.lang.String value)
key
- The custom data key.value
- The value for the key.public static void setCustomerId(@Nullable java.lang.String customerId)
customerId
- Customer's id.setIdentifier(String, String)
public static void setCustomerIdWithPrivacyOptedOut(@Nullable java.lang.String customerId, boolean optedOut)
customerId
- Customer's id.optedOut
- True if the user should be privacy opted out and have all his Localytics data deleted.setPrivacyOptedOut(boolean)
,
setCustomerId(String)
public static java.lang.String getCustomerId()
public static java.lang.String getIdentifier(java.lang.String key)
key
- The key for an identifier.setIdentifier(String, String)
public static void setLocation(android.location.Location location)
location
- User's location.public static void onActivityResume(@NonNull android.app.Activity activity)
This will: ~ open a new session ~ kick off an uplaod ~ handle test mode ~ handle opening a push notification ~ allow an activity of type FragmentActivity to display a marketing message
activity
- The current Activitypublic static void onActivityPause(android.app.Activity activity)
This will: ~ close an existing session ~ kick off an upload ~ dismiss a currently displayed marketing message
activity
- The current Activitypublic static void onNewIntent(android.app.Activity activity, android.content.Intent intent)
onActivityResume(Activity, Intent)
but with the new Intentactivity
- The current Activityintent
- The new IntentonActivityResume(Activity, Intent)
public static void setOptions(@NonNull java.util.Map<java.lang.String,java.lang.Object> options)
options
- The map of options and values to modifypublic static void setOption(@NonNull java.lang.String key, @Nullable java.lang.Object value)
key
- The key of the optionvalue
- The value of the option or null to restore the defaultpublic static void setLoggingEnabled(boolean enabled)
enabled
- Flag to indicate whether the logging should be enabled or disabled.isLoggingEnabled()
public static void redirectLogsToDisk(boolean writeExternally, @NonNull android.content.Context context)
writeExternally
- a boolean value to indicate where to write the logs.context
- The Application's Context object.public static boolean isLoggingEnabled()
setLoggingEnabled(boolean)
public static java.lang.String getInstallId()
public static java.lang.String getLocalAuthenticationToken()
public static java.lang.String getAppKey()
@NonNull public static java.lang.String getLibraryVersion()
public static void setInAppMessageDismissButtonLocation(Localytics.InAppMessageDismissButtonLocation buttonLocation)
buttonLocation
- The button location.getInAppMessageDismissButtonLocation()
public static Localytics.InAppMessageDismissButtonLocation getInAppMessageDismissButtonLocation()
setInAppMessageDismissButtonLocation(com.localytics.android.Localytics.InAppMessageDismissButtonLocation)