public class Leanplum
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ACTION_KIND_ACTION |
static int |
ACTION_KIND_MESSAGE |
static java.lang.String |
PURCHASE_EVENT_NAME
Default event name to use for Purchase events.
|
Modifier and Type | Method and Description |
---|---|
static void |
addOnceVariablesChangedAndNoDownloadsPendingHandler(VariablesChangedCallback handler)
Add a callback to call ONCE when no more file downloads are pending (either when no files
needed to be downloaded or all downloads have been completed).
|
static void |
addStartResponseHandler(StartCallback handler)
Add a callback for when the start call finishes, and variables are returned back from the
server.
|
static void |
addVariablesChangedAndNoDownloadsPendingHandler(VariablesChangedCallback handler)
Add a callback for when no more file downloads are pending (either when no files needed to be
downloaded or all downloads have been completed).
|
static void |
addVariablesChangedHandler(VariablesChangedCallback handler)
Add a callback for when the variables receive new values from the server.
|
static void |
advanceTo(java.lang.String state)
Advances to a particular state in your application.
|
static void |
advanceTo(java.lang.String state,
java.util.Map<java.lang.String,?> params)
Advances to a particular state in your application.
|
static void |
advanceTo(java.lang.String state,
java.lang.String info)
Advances to a particular state in your application.
|
static void |
advanceTo(java.lang.String state,
java.lang.String info,
java.util.Map<java.lang.String,?> params)
Advances to a particular state in your application.
|
static void |
defineAction(java.lang.String name,
int kind,
ActionArgs args)
Defines an action that is used within Leanplum Marketing Automation.
|
static void |
defineAction(java.lang.String name,
int kind,
ActionArgs args,
ActionCallback responder)
Defines an action that is used within Leanplum Marketing Automation.
|
static void |
disableLocationCollection()
Disable location collection by setting |locationCollectionEnabled| to false.
|
static void |
enableTestMode()
This should be your first statement in a unit test.
|
static void |
enableVerboseLoggingInDevelopmentMode()
Optional.
|
static void |
forceContentUpdate()
Forces content to update from the server.
|
static void |
forceContentUpdate(VariablesChangedCallback callback)
Forces content to update from the server.
|
static android.content.Context |
getContext()
Gets the application context.
|
static java.lang.String |
getDeviceId()
Gets the deviceId in the current Leanplum session.
|
static LeanplumInbox |
getInbox()
Returns an instance to the singleton LeanplumInbox object.
|
static java.lang.String |
getUserId()
Returns the userId in the current Leanplum session.
|
static java.util.Map<java.lang.String,java.lang.Object> |
getVariantDebugInfo()
Details about the variable assignments on the server.
|
static boolean |
hasStarted()
Whether or not Leanplum has finished starting.
|
static boolean |
hasStartedAndRegisteredAsDeveloper()
Whether or not Leanplum has finished starting and the device is registered as a developer.
|
static boolean |
isInterfaceEditingEnabled()
Whether interface editing is enabled or not.
|
static boolean |
isLocationCollectionEnabled()
Returns whether a customer enabled location collection.
|
static boolean |
isResourceSyncingEnabled()
Returns true if resource syncing is enabled.
|
static boolean |
isScreenTrackingEnabled()
Whether screen tracking is enabled or not.
|
static boolean |
isTestModeEnabled() |
static java.util.Map<java.lang.String,java.lang.Object> |
messageMetadata()
Returns metadata for all active in-app messages.
|
static java.lang.Object |
objectForKeyPath(java.lang.Object... components)
Traverses the variable structure with the specified path.
|
static java.lang.Object |
objectForKeyPathComponents(java.lang.Object[] pathComponents)
Traverses the variable structure with the specified path.
|
static void |
onAction(java.lang.String actionName,
ActionCallback handler)
Adds a callback that handles an action with the given name.
|
static java.lang.String |
pathForResource(java.lang.String filename)
Gets the path for a particular resource.
|
static void |
pauseState()
Pauses the current state.
|
static void |
removeOnceVariablesChangedAndNoDownloadsPendingHandler(VariablesChangedCallback handler)
Removes a once variables changed and no downloads pending callback.
|
static void |
removeStartResponseHandler(StartCallback handler)
Removes a start response callback.
|
static void |
removeVariablesChangedAndNoDownloadsPendingHandler(VariablesChangedCallback handler)
Removes a variables changed and no downloads pending callback.
|
static void |
removeVariablesChangedHandler(VariablesChangedCallback handler)
Removes a variables changed callback.
|
static void |
resumeState()
Resumes the current state.
|
static void |
setApiConnectionSettings(java.lang.String hostName,
java.lang.String servletName,
boolean ssl)
Optional.
|
static void |
setAppIdForDevelopmentMode(java.lang.String appId,
java.lang.String accessKey)
Must call either this or
setAppIdForProductionMode(java.lang.String, java.lang.String) before issuing any calls to
the API, including start. |
static void |
setAppIdForProductionMode(java.lang.String appId,
java.lang.String accessKey)
Must call either this or
setAppIdForDevelopmentMode(java.lang.String, java.lang.String) before issuing any calls
to the API, including start. |
static void |
setApplicationContext(android.content.Context context)
Sets the application context.
|
static void |
setCanDownloadContentMidSessionInProductionMode(boolean value)
Advanced: Whether new variables can be downloaded mid-session.
|
static void |
setDeviceId(java.lang.String deviceId)
(Advanced) Sets a custom device ID.
|
static void |
setDeviceIdMode(LeanplumDeviceIdMode mode)
Sets the type of device ID to use.
|
static void |
setDeviceLocation(android.location.Location location)
Set location manually.
|
static void |
setDeviceLocation(android.location.Location location,
LeanplumLocationAccuracyType type)
Set location manually.
|
static void |
setFileHashingEnabledInDevelopmentMode(boolean enabled)
Optional.
|
static void |
setFileUploadingEnabledInDevelopmentMode(boolean enabled)
Optional.
|
static void |
setIsTestModeEnabled(boolean isTestModeEnabled)
This should be your first statement in a unit test.
|
static void |
setNetworkTimeout(int seconds,
int downloadSeconds)
Optional.
|
static void |
setSocketConnectionSettings(java.lang.String hostName,
int port)
Optional.
|
static void |
setTrafficSourceInfo(java.util.Map<java.lang.String,java.lang.String> info)
Sets the traffic source info for the current user.
|
static void |
setUserAttributes(java.util.Map<java.lang.String,java.lang.Object> userAttributes)
Adds or modifies user attributes.
|
static void |
setUserAttributes(java.lang.String userId,
java.util.Map<java.lang.String,?> userAttributes)
Updates the user ID and adds or modifies user attributes.
|
static void |
setUserId(java.lang.String userId)
Updates the user ID.
|
static void |
setVariantDebugInfoEnabled(boolean variantDebugInfoEnabled)
Set this to true if you want details about the variable assignments
on the server.
|
static void |
start(android.content.Context context)
Call this when your application starts.
|
static void |
start(android.content.Context context,
java.util.Map<java.lang.String,?> userAttributes)
Call this when your application starts.
|
static void |
start(android.content.Context context,
StartCallback callback)
Call this when your application starts.
|
static void |
start(android.content.Context context,
java.lang.String userId)
Call this when your application starts.
|
static void |
start(android.content.Context context,
java.lang.String userId,
java.util.Map<java.lang.String,?> userAttributes)
Call this when your application starts.
|
static void |
start(android.content.Context context,
java.lang.String userId,
java.util.Map<java.lang.String,?> attributes,
StartCallback response)
Call this when your application starts.
|
static void |
start(android.content.Context context,
java.lang.String userId,
StartCallback callback)
Call this when your application starts.
|
static void |
syncResources()
Syncs resources between Leanplum and the current app.
|
static void |
syncResources(java.util.List<java.lang.String> patternsToInclude,
java.util.List<java.lang.String> patternsToExclude)
Syncs resources between Leanplum and the current app.
|
static void |
syncResourcesAsync()
Syncs resources between Leanplum and the current app.
|
static void |
syncResourcesAsync(java.util.List<java.lang.String> patternsToInclude,
java.util.List<java.lang.String> patternsToExclude)
Syncs resources between Leanplum and the current app.
|
static void |
track(java.lang.String event)
Logs a particular event in your application.
|
static void |
track(java.lang.String event,
double value)
Logs a particular event in your application.
|
static void |
track(java.lang.String event,
double value,
java.util.Map<java.lang.String,?> params)
Logs a particular event in your application.
|
static void |
track(java.lang.String event,
double value,
java.lang.String info)
Logs a particular event in your application.
|
static void |
track(java.lang.String event,
double value,
java.lang.String info,
java.util.Map<java.lang.String,?> params)
Logs a particular event in your application.
|
static void |
track(java.lang.String event,
java.util.Map<java.lang.String,?> params)
Logs a particular event in your application.
|
static void |
track(java.lang.String event,
java.lang.String info)
Logs a particular event in your application.
|
static void |
trackAllAppScreens()
Enable screen tracking.
|
static void |
trackGooglePlayPurchase(java.lang.String item,
long priceMicros,
java.lang.String currencyCode,
java.lang.String purchaseData,
java.lang.String dataSignature)
Tracks an in-app purchase as a Purchase event.
|
static void |
trackGooglePlayPurchase(java.lang.String item,
long priceMicros,
java.lang.String currencyCode,
java.lang.String purchaseData,
java.lang.String dataSignature,
java.util.Map<java.lang.String,?> params)
Tracks an in-app purchase as a Purchase event.
|
static void |
trackGooglePlayPurchase(java.lang.String eventName,
java.lang.String item,
long priceMicros,
java.lang.String currencyCode,
java.lang.String purchaseData,
java.lang.String dataSignature,
java.util.Map<java.lang.String,?> params)
Tracks an in-app purchase.
|
static void |
trackPurchase(java.lang.String event,
double value,
java.lang.String currencyCode,
java.util.Map<java.lang.String,?> params)
Manually track purchase event with currency code in your application.
|
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
variants()
Returns information about the active variants for the current user.
|
public static final int ACTION_KIND_MESSAGE
public static final int ACTION_KIND_ACTION
public static final java.lang.String PURCHASE_EVENT_NAME
public static void setApiConnectionSettings(java.lang.String hostName, java.lang.String servletName, boolean ssl)
hostName
- The name of the API host, such as www.leanplum.comservletName
- The name of the API servlet, such as apissl
- Whether to use SSLpublic static void setSocketConnectionSettings(java.lang.String hostName, int port)
hostName
- The host name of the socket server.port
- The port to connect to.public static void setFileHashingEnabledInDevelopmentMode(boolean enabled)
enabled
- Setting this to false will reduce startup latency in development mode, but it's
possible that Leanplum will always have the most up-to-date versions of your resources.
(Default: true)public static void setFileUploadingEnabledInDevelopmentMode(boolean enabled)
enabled
- Whether or not files should be uploaded. (Default: true)public static void enableVerboseLoggingInDevelopmentMode()
public static void setNetworkTimeout(int seconds, int downloadSeconds)
public static void setCanDownloadContentMidSessionInProductionMode(boolean value)
public static void setAppIdForDevelopmentMode(java.lang.String appId, java.lang.String accessKey)
setAppIdForProductionMode(java.lang.String, java.lang.String)
before issuing any calls to
the API, including start.appId
- Your app ID.accessKey
- Your development key.public static void setAppIdForProductionMode(java.lang.String appId, java.lang.String accessKey)
setAppIdForDevelopmentMode(java.lang.String, java.lang.String)
before issuing any calls
to the API, including start.appId
- Your app ID.accessKey
- Your production key.public static void trackAllAppScreens()
public static void setVariantDebugInfoEnabled(boolean variantDebugInfoEnabled)
public static boolean isScreenTrackingEnabled()
public static boolean isInterfaceEditingEnabled()
public static void setDeviceIdMode(LeanplumDeviceIdMode mode)
LeanplumDeviceIdMode.MD5_MAC_ADDRESS
public static void setDeviceId(java.lang.String deviceId)
public static java.lang.String getDeviceId()
start(android.content.Context)
.public static void setApplicationContext(android.content.Context context)
public static android.content.Context getContext()
public static void syncResources()
start(android.content.Context)
. syncResourcesAsync should be used instead unless file variables
need to be defined earlypublic static void syncResourcesAsync()
start(android.content.Context)
.public static void syncResources(java.util.List<java.lang.String> patternsToInclude, java.util.List<java.lang.String> patternsToExclude)
start(android.content.Context)
. syncResourcesAsync should be used instead unless file variables
need to be defined earlypatternsToInclude
- Limit paths to only those matching at least one pattern in this list.
Supply null to indicate no inclusion patterns. Paths start with the folder name within the res
folder, e.g. "layout/main.xml".patternsToExclude
- Exclude paths matching at least one of these patterns. Supply null to
indicate no exclusion patterns.public static void syncResourcesAsync(java.util.List<java.lang.String> patternsToInclude, java.util.List<java.lang.String> patternsToExclude)
start(android.content.Context)
. syncResourcesAsync should be used instead unless file variables
need to be defined earlypatternsToInclude
- Limit paths to only those matching at least one pattern in this list.
Supply null to indicate no inclusion patterns. Paths start with the folder name within the res
folder, e.g. "layout/main.xml".patternsToExclude
- Exclude paths matching at least one of these patterns. Supply null to
indicate no exclusion patterns.public static boolean isResourceSyncingEnabled()
public static void start(android.content.Context context)
public static void start(android.content.Context context, StartCallback callback)
public static void start(android.content.Context context, java.util.Map<java.lang.String,?> userAttributes)
public static void start(android.content.Context context, java.lang.String userId)
public static void start(android.content.Context context, java.lang.String userId, StartCallback callback)
public static void start(android.content.Context context, java.lang.String userId, java.util.Map<java.lang.String,?> userAttributes)
public static void start(android.content.Context context, java.lang.String userId, java.util.Map<java.lang.String,?> attributes, StartCallback response)
public static boolean hasStarted()
public static java.lang.String getUserId()
public static LeanplumInbox getInbox()
public static boolean hasStartedAndRegisteredAsDeveloper()
public static void addStartResponseHandler(StartCallback handler)
public static void removeStartResponseHandler(StartCallback handler)
public static void addVariablesChangedHandler(VariablesChangedCallback handler)
public static void removeVariablesChangedHandler(VariablesChangedCallback handler)
public static void addVariablesChangedAndNoDownloadsPendingHandler(VariablesChangedCallback handler)
public static void removeVariablesChangedAndNoDownloadsPendingHandler(VariablesChangedCallback handler)
public static void addOnceVariablesChangedAndNoDownloadsPendingHandler(VariablesChangedCallback handler)
public static void removeOnceVariablesChangedAndNoDownloadsPendingHandler(VariablesChangedCallback handler)
public static void defineAction(java.lang.String name, int kind, ActionArgs args)
onAction(java.lang.String, com.leanplum.callbacks.ActionCallback)
to handle
the action.name
- The name of the action to register.kind
- Whether to display the action as a message and/or a regular action.args
- User-customizable options for the action.public static void defineAction(java.lang.String name, int kind, ActionArgs args, ActionCallback responder)
name
- The name of the action to register.kind
- Whether to display the action as a message and/or a regular action.args
- User-customizable options for the action.responder
- Called when the action is triggered with a context object containing the
user-specified options.public static void onAction(java.lang.String actionName, ActionCallback handler)
actionName
- The name of the type of action to handle.handler
- The callback that runs when the action is triggered.public static void setUserAttributes(java.lang.String userId, java.util.Map<java.lang.String,?> userAttributes)
public static void setUserId(java.lang.String userId)
public static void setUserAttributes(java.util.Map<java.lang.String,java.lang.Object> userAttributes)
public static void setTrafficSourceInfo(java.util.Map<java.lang.String,java.lang.String> info)
public static void track(java.lang.String event, double value, java.lang.String info, java.util.Map<java.lang.String,?> params)
To track Purchase events, call trackGooglePlayPurchase(java.lang.String, long, java.lang.String, java.lang.String, java.lang.String)
instead for in-app
purchases, or use PURCHASE_EVENT_NAME
as the event name for other types of
purchases.
event
- Name of the event. Event may be empty for message impression events.value
- The value of the event. The value is special in that you can use it for targeting
content and messages to users who have a particular lifetime value. For purchase events, the
value is the revenue associated with the purchase.info
- Basic context associated with the event, such as the item purchased. info is
treated like a default parameter.params
- Key-value pairs with metrics or data associated with the event. Parameters can be
strings or numbers. You can use up to 200 different parameter names in your app.public static void trackPurchase(java.lang.String event, double value, java.lang.String currencyCode, java.util.Map<java.lang.String,?> params)
trackGooglePlayPurchase(java.lang.String, long, java.lang.String, java.lang.String, java.lang.String)
instead for in-app purchases.event
- Name of the event.value
- The value of the event. Can be price.currencyCode
- The currency code corresponding to the price.params
- Key-value pairs with metrics or data associated with the event. Parameters can be
strings or numbers. You can use up to 200 different parameter names in your app.public static void trackGooglePlayPurchase(java.lang.String item, long priceMicros, java.lang.String currencyCode, java.lang.String purchaseData, java.lang.String dataSignature)
item
- The name of the item that was purchased.priceMicros
- The price in micros in the user's local currency.currencyCode
- The currency code corresponding to the price.purchaseData
- Purchase data from purchase.getOriginalJson().dataSignature
- Signature from purchase.getSignature().public static void trackGooglePlayPurchase(java.lang.String item, long priceMicros, java.lang.String currencyCode, java.lang.String purchaseData, java.lang.String dataSignature, java.util.Map<java.lang.String,?> params)
item
- The name of the item that was purchased.priceMicros
- The price in micros in the user's local currency.currencyCode
- The currency code corresponding to the price.purchaseData
- Purchase data from purchase.getOriginalJson().dataSignature
- Signature from purchase.getSignature().params
- Any additional parameters to track with the event.public static void trackGooglePlayPurchase(java.lang.String eventName, java.lang.String item, long priceMicros, java.lang.String currencyCode, java.lang.String purchaseData, java.lang.String dataSignature, java.util.Map<java.lang.String,?> params)
eventName
- The name of the event to record the purchase under. Normally, this would be
PURCHASE_EVENT_NAME
.item
- The name of the item that was purchased.priceMicros
- The price in micros in the user's local currency.currencyCode
- The currency code corresponding to the price.purchaseData
- Purchase data from purchase.getOriginalJson().dataSignature
- Signature from purchase.getSignature().params
- Any additional parameters to track with the event.public static void track(java.lang.String event)
To track Purchase events, use PURCHASE_EVENT_NAME
.
event
- Name of the event.public static void track(java.lang.String event, double value)
To track Purchase events, use PURCHASE_EVENT_NAME
.
event
- Name of the event.value
- The value of the event. The value is special in that you can use it for targeting
content and messages to users who have a particular lifetime value. For purchase events, the
value is the revenue associated with the purchase.public static void track(java.lang.String event, java.lang.String info)
To track Purchase events, use PURCHASE_EVENT_NAME
.
event
- Name of the event.info
- Basic context associated with the event, such as the item purchased. info is
treated like a default parameter.public static void track(java.lang.String event, java.util.Map<java.lang.String,?> params)
To track Purchase events, use PURCHASE_EVENT_NAME
.
event
- Name of the event.params
- Key-value pairs with metrics or data associated with the event. Parameters can be
strings or numbers. You can use up to 200 different parameter names in your app.public static void track(java.lang.String event, double value, java.util.Map<java.lang.String,?> params)
To track Purchase events, use PURCHASE_EVENT_NAME
.
event
- Name of the event.value
- The value of the event. The value is special in that you can use it for targeting
content and messages to users who have a particular lifetime value. For purchase events, the
value is the revenue associated with the purchase.params
- Key-value pairs with metrics or data associated with the event. Parameters can be
strings or numbers. You can use up to 200 different parameter names in your app.public static void track(java.lang.String event, double value, java.lang.String info)
To track Purchase events, use PURCHASE_EVENT_NAME
.
event
- Name of the event.value
- The value of the event. The value is special in that you can use it for targeting
content and messages to users who have a particular lifetime value. For purchase events, the
value is the revenue associated with the purchase.info
- Basic context associated with the event, such as the item purchased. info is
treated like a default parameter.public static void advanceTo(java.lang.String state, java.lang.String info, java.util.Map<java.lang.String,?> params)
state
- Name of the state. State may be empty for message impression events.info
- Basic context associated with the state, such as the item purchased. info is
treated like a default parameter.params
- Key-value pairs with metrics or data associated with the state. Parameters can be
strings or numbers. You can use up to 200 different parameter names in your app.public static void advanceTo(java.lang.String state)
state
- Name of the state. State may be empty for message impression events.public static void advanceTo(java.lang.String state, java.lang.String info)
state
- Name of the state. State may be empty for message impression events.info
- Basic context associated with the state, such as the item purchased. info is
treated like a default parameter.public static void advanceTo(java.lang.String state, java.util.Map<java.lang.String,?> params)
state
- Name of the state. State may be empty for message impression events.params
- Key-value pairs with metrics or data associated with the state. Parameters can be
strings or numbers. You can use up to 200 different parameter names in your app.public static void pauseState()
public static void resumeState()
public static void forceContentUpdate()
public static void forceContentUpdate(VariablesChangedCallback callback)
callback
- The callback to invoke when the call completes from the server. The callback
will fire regardless of whether the variables have changed.public static void enableTestMode()
public static boolean isTestModeEnabled()
public static void setIsTestModeEnabled(boolean isTestModeEnabled)
public static java.lang.String pathForResource(java.lang.String filename)
public static java.lang.Object objectForKeyPath(java.lang.Object... components)
public static java.lang.Object objectForKeyPathComponents(java.lang.Object[] pathComponents)
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> variants()
public static java.util.Map<java.lang.String,java.lang.Object> messageMetadata()
public static java.util.Map<java.lang.String,java.lang.Object> getVariantDebugInfo()
public static void setDeviceLocation(android.location.Location location)
location
- Device location.public static void setDeviceLocation(android.location.Location location, LeanplumLocationAccuracyType type)
location
- Device location.type
- LeanplumLocationAccuracyType of the location.public static void disableLocationCollection()
public static boolean isLocationCollectionEnabled()