Package com.batch.android
Class Batch.User
java.lang.Object
com.batch.android.Batch.User
- Enclosing class:
- Batch
Batch User module
-
Method Summary
Modifier and TypeMethodDescriptionstatic BatchUserDataEditor
editor()
Get the user data editor.static void
fetchAttributes
(Context context, BatchAttributesFetchListener listener) Read the saved attributes.static void
fetchTagCollections
(Context context, BatchTagCollectionsFetchListener listener) Read the saved tag collections.static BatchUserDataEditor
Deprecated.static String
getIdentifier
(Context context) Read the custom identifier.static String
Get the unique installation ID, generated by Batch.static String
getLanguage
(Context context) Read the language.static String
Read the region.static void
Print the currently known attributes and tags for a user to logcat.static void
trackEvent
(String event) Track an event.static void
trackEvent
(String event, String label) Track an event.static void
trackEvent
(String event, String label, BatchEventData data) Track an event.static void
trackEvent
(String event, String label, JSONObject data) Deprecated.static void
trackLocation
(Location location) Track a location update.static void
trackTransaction
(double amount) Track a transaction.static void
trackTransaction
(double amount, JSONObject data) Track a transaction.
-
Method Details
-
getInstallationID
Get the unique installation ID, generated by Batch. Batch must be started to read it.- Returns:
- Batch-generated installation ID. Might be null if Batch isn't started.
-
getLanguage
Read the language.- Returns:
- The custom language set with
BatchUserDataEditor
. Returns null by default.
-
getRegion
Read the region.- Returns:
- The custom region set with
BatchUserDataEditor
. Returns null by default.
-
getIdentifier
Read the custom identifier.- Returns:
- The custom identifier set with
BatchUserDataEditor
. Returns null by default.
-
getEditor
Deprecated.Useeditor()
Get the user data editor. Batch must be started to save it.- Returns:
- A BatchUserDataEditor instance.
-
editor
Get the user data editor. Batch must be started to save it. Note that you should chain calls to the returned editor. If you call this method again, you will get another editor that's not aware of changes made elsewhere that have not been saved.- Returns:
- A BatchUserDataEditor instance.
-
fetchAttributes
Read the saved attributes. Reading is asynchronous so as not to interfere with saving operations.- Parameters:
context
-listener
- Pass a listener to be notified of the fetch result.
-
fetchTagCollections
Read the saved tag collections. Reading is asynchronous so as not to interfere with saving operations.- Parameters:
context
-listener
- Pass a listener to be notified of the fetch result.
-
trackEvent
Track an event. You can call this method from any thread. Batch must be started at some point, or events won't be sent to the server.- Parameters:
event
- The event name.
-
trackEvent
Track an event. You can call this method from any thread. Batch must be started at some point, or events won't be sent to the server.- Parameters:
event
- The event name.label
- The event label. Can be null.
-
trackEvent
Deprecated.SeeBatch.User#trackEvent(String, String, BatchEventData)
. Data sent using this method might be truncated if it can't be converted to aBatchEventData
instance.Track an event. You can call this method from any thread. Batch must be started at some point, or events won't be sent to the server.- Parameters:
event
- The event name.label
- The event label. Can be null.data
- The event data. Can be null.
-
trackEvent
Track an event. You can call this method from any thread. Batch must be started at some point, or events won't be sent to the server.- Parameters:
event
- The event name.label
- The event label. Can be null.data
- The event data. Can be null.
-
trackLocation
Track a location update. You can call this method from any thread. Batch must be started at some point, or location updates won't be sent to the server.
The location object usually comes from the location system service, or the Fused Location API, but can also manually create it.
If you manually create it, please make sure to fill the accuracy and date if you have that data: both of these values are used to improve the targeting.- Parameters:
location
- The location. Can't be null.
-
trackTransaction
public static void trackTransaction(double amount) Track a transaction. You can call this method from any thread. Batch must be started at some point, or events won't be sent to the server.- Parameters:
amount
- Transaction amount.
-
trackTransaction
Track a transaction. You can call this method from any thread. Batch must be started at some point, or events won't be sent to the server.- Parameters:
amount
- Transaction amount.data
- Transaction data. Can be null.
-
printDebugInformation
public static void printDebugInformation()Print the currently known attributes and tags for a user to logcat.For debug purposes only. Don't rely on the log format, because it can change at any time without warning.
-
editor()