Class Batch.User

  • Enclosing class:
    Batch

    public static final class Batch.User
    extends java.lang.Object
    Batch User module
    • Method Detail

      • getInstallationID

        @Nullable
        public static java.lang.String 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

        @Nullable
        public static java.lang.String getLanguage​(@NonNull
                                                   android.content.Context context)
        Read the language.
        Returns:
        The custom language set with BatchUserDataEditor. Returns null by default.
      • getRegion

        @Nullable
        public static java.lang.String getRegion​(@NonNull
                                                 android.content.Context context)
        Read the region.
        Returns:
        The custom region set with BatchUserDataEditor. Returns null by default.
      • getIdentifier

        @Nullable
        public static java.lang.String getIdentifier​(@NonNull
                                                     android.content.Context context)
        Read the custom identifier.
        Returns:
        The custom identifier set with BatchUserDataEditor. Returns null by default.
      • getEditor

        @Deprecated
        public static BatchUserDataEditor getEditor()
        Deprecated.
        Get the user data editor. Batch must be started to save it.
        Returns:
        A BatchUserDataEditor instance.
      • editor

        public static BatchUserDataEditor 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

        public static void fetchAttributes​(@NonNull
                                           android.content.Context context,
                                           @Nullable
                                           BatchAttributesFetchListener listener)
        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

        public static void fetchTagCollections​(@NonNull
                                               android.content.Context context,
                                               @Nullable
                                               BatchTagCollectionsFetchListener listener)
        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

        public static void trackEvent​(@NonNull
                                      java.lang.String event)
        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

        public static void trackEvent​(@NonNull
                                      java.lang.String event,
                                      java.lang.String label)
        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
        public static void trackEvent​(@NonNull
                                      java.lang.String event,
                                      java.lang.String label,
                                      JSONObject data)
        Deprecated.
        See trackEvent(String, String, BatchEventData). Data sent using this method might be truncated if it can't be converted to a BatchEventData 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

        public static void trackEvent​(@NonNull
                                      java.lang.String event,
                                      java.lang.String label,
                                      BatchEventData data)
        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

        public static void trackLocation​(@NonNull
                                         android.location.Location location)
        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

        public static void trackTransaction​(double amount,
                                            JSONObject data)
        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.