-
public final class BatchEntry point of the Batch library
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classBatch.DebugBatch Debug module
public final classBatch.InboxBatch Inbox module
public final classBatch.PushBatch Push module
public final classBatch.EventDispatcherBatch EventDispatcher module
public final classBatch.UserBatch User module
public final classBatch.ProfileBatch Profile module
public final classBatch.MessagingBatch Messaging module
public final classBatch.ActionsBatch Action manager
-
Field Summary
Fields Modifier and Type Field Description private static StringsessionIDpublic final static StringNOTIFICATION_TAGpublic final static StringBROADCAST_PERMISSION_SUFFIXpublic final static StringACTION_REGISTRATION_IDENTIFIER_OBTAINEDpublic final static StringEXTRA_REGISTRATION_IDENTIFIERpublic final static StringEXTRA_REGISTRATION_PROVIDER_NAMEpublic final static StringEXTRA_REGISTRATION_SENDER_ID
-
Method Summary
Modifier and Type Method Description static StringgetSessionID()Get the id of the current session, random uuid used internally by Batch to identify the app session. static voidstart(@NonNull() String apiKey)Set the API Key of Batch. static voiddisableMigration(@NonNull() EnumSet<BatchMigration> migrations)Set data migrations you want to disable. static voidsetLoggerDelegate(@Nullable() LoggerDelegate delegate)Set if Batch should send its logs to an object of yours (default = null)Be careful with your implementation: setting this can impact stability and performanceYou should only use it if you know what you are doing. static voidsetLoggerLevel(@NonNull() LoggerLevel level)Set the log level that Batch should use static voidupdateAutomaticDataCollection(BatchDataCollectionConfig.Editor editor)Configure the SDK Automatic Data Collection. static voidcopyBatchExtras(@Nullable() Intent from, @Nullable() Intent to)Copy Batch's internal data from an intent to another.This is useful if you've got an activity that will not get a chance to start Batch before closing itself,but don't want to break features relying on data put in the intent extras, such as direct open trackingor mobile landings. static voidcopyBatchExtras(@Nullable() Bundle from, @Nullable() Bundle to)Copy Batch's internal data from intent extras to another bundle.This is useful if you've got an activity that will not get a chance to start Batch before closing itself,but don't want to break features relying on data put in the intent extras, such as direct open trackingor mobile landings. static StringgetBroadcastPermissionName(@NonNull() Context context)Get the broadcast permission name. static voidoptOut(@NonNull() Context context)Opt Out from Batch SDK Usage. static voidoptOut(@NonNull() Context context, @Nullable() BatchOptOutResultListener listener)Opt Out from Batch SDK Usage. static voidoptOutAndWipeData(@NonNull() Context context)Opt Out from Batch SDK Usage. static voidoptOutAndWipeData(@NonNull() Context context, @Nullable() BatchOptOutResultListener listener)Opt Out from Batch SDK Usage. static voidoptIn(@NonNull() Context context)Opt In to Batch SDK Usage. static booleanisOptedOut(@NonNull() Context context)Returns whether Batch has been opted out from or notWarning: This method might perform some quick I/O in the caller thread. static voidsetFindMyInstallationEnabled(boolean enabled)Control whether Batch should enables the Find My Installation feature (default = true)If enabled Batch will copy the current installation id in the clipboard when the applicationis foregrounded 5 times within 12 seconds. static voidonCreate(Activity activity)Method to call on your main activity onCreate. static voidonStart(Activity activity)Method to call on your main activity onStart to start Batch and support URL scheme events. static voidonServiceCreate(Context context, boolean userActivity)Method to call on your service onCreate to start Batch. static voidonServiceDestroy(Context context)Method to call on your service onDestroy to stop Batch. static voidonNewIntent(Activity activity, Intent intent)Method to call on your main activity onNewIntentCalling this method if Batch is already stopped or not started will do nothing static voidonStop(Activity activity)Method to call on your main activity onStopCalling this method if Batch is already stopped or not started will do nothing static voidonDestroy(Activity activity)Method to call on your main activity onDestroyCalling this method if Batch is already stopped or not started will do nothing -
-
Method Detail
-
getSessionID
@Nullable() static String getSessionID()
Get the id of the current session, random uuid used internally by Batch to identify the app session.
-
start
static void start(@NonNull() String apiKey)
Set the API Key of Batch.You should call this method before any other, only one time.Typically on the onCreate of your Application class.
- Parameters:
apiKey- Your Batch API Key
-
disableMigration
static void disableMigration(@NonNull() EnumSet<BatchMigration> migrations)
Set data migrations you want to disable.
- Parameters:
migrations- EnumSet of Migrations to disable.
-
setLoggerDelegate
static void setLoggerDelegate(@Nullable() LoggerDelegate delegate)
Set if Batch should send its logs to an object of yours (default = null)Be careful with your implementation: setting this can impact stability and performanceYou should only use it if you know what you are doing.
- Parameters:
delegate- An object implementing LoggerDelegate
-
setLoggerLevel
static void setLoggerLevel(@NonNull() LoggerLevel level)
Set the log level that Batch should use
- Parameters:
level- The level of the logger to use
-
updateAutomaticDataCollection
static void updateAutomaticDataCollection(BatchDataCollectionConfig.Editor editor)
Configure the SDK Automatic Data Collection.
- Parameters:
editor- A callback which will be called with an instance of the data collection config.Once your callback ends, Batch will persist the changes.
-
copyBatchExtras
static void copyBatchExtras(@Nullable() Intent from, @Nullable() Intent to)
Copy Batch's internal data from an intent to another.This is useful if you've got an activity that will not get a chance to start Batch before closing itself,but don't want to break features relying on data put in the intent extras, such as direct open trackingor mobile landings.
- Parameters:
from- Intent to read Batch's data fromto- Intent to copy Batch's data to
-
copyBatchExtras
static void copyBatchExtras(@Nullable() Bundle from, @Nullable() Bundle to)
Copy Batch's internal data from intent extras to another bundle.This is useful if you've got an activity that will not get a chance to start Batch before closing itself,but don't want to break features relying on data put in the intent extras, such as direct open trackingor mobile landings.
- Parameters:
from- Intent to read Batch's data fromto- Intent to copy Batch's data to
-
getBroadcastPermissionName
@NonNull() static String getBroadcastPermissionName(@NonNull() Context context)
Get the broadcast permission name.
Useful if you want to register your broadcast receiver at runtime
-
optOut
static void optOut(@NonNull() Context context)
Opt Out from Batch SDK Usage. Requires Batch to be started.
Note that calling the SDK when opted out is discouraged: Some modules might behave unexpectedlywhen the SDK is opted-out from.
Opting out will:- Prevent onStart or onServiceCreate from doing anything at all- Disable any network capability from the SDK- Disable all In-App campaigns- Make the Inbox module return an error immediately when used- Make the SDK reject any BatchUserProfile or save calls- Make the SDK reject calls to trackEvent, trackLocation and any related methods
Even if you opt in afterwards, data that has been generated while opted out WILL be lost.
If you're also looking at deleting user data, please use optOutAndWipeData
Note that calling this method will stop Batch, effectively simulating calls to onStop, onDestroy and onServiceDestroy.Your app should be prepared to handle these cases.Some features might not be disabled until the next app start.
-
optOut
static void optOut(@NonNull() Context context, @Nullable() BatchOptOutResultListener listener)
Opt Out from Batch SDK Usage. Requires Batch to be started.
Same as optOut, with a completion listener.
Use the listener to be informed about whether the opt-out request has been successfully sent to the server or not.You'll also be able to control what to do in case of failure.
Note: if the SDK has already been opted-out from, this method will instantly call the listener with a *failure* state.
-
optOutAndWipeData
static void optOutAndWipeData(@NonNull() Context context)
Opt Out from Batch SDK Usage. Requires Batch to be started.
Same as optOut but also wipes data.
Note that calling this method will stop Batch, effectively simulating calls to onStop, onDestroy and onServiceDestroy.Your app should be prepared to handle these cases.
-
optOutAndWipeData
static void optOutAndWipeData(@NonNull() Context context, @Nullable() BatchOptOutResultListener listener)
Opt Out from Batch SDK Usage. Requires Batch to be started.
Same as optOut but also wipes data.
Note that calling this method will stop Batch, effectively simulating calls to onStop, onDestroy and onServiceDestroy.Your app should be prepared to handle these cases.
Use the listener to be informed about whether the opt-out request has been successfully sent to the server or not.You'll also be able to control what to do in case of failure.
Note: if the SDK has already been opted-out from, this method will instantly call the listener with a *failure* state.
-
optIn
static void optIn(@NonNull() Context context)
Opt In to Batch SDK Usage.
This method will be taken into account on next full application start (full process restart)
Only useful if you called optOut or optOutAndWipeData or opted out by default in the manifest
Some features might not be disabled until the next app start if you call this late into the application's life. It is stronglyadvised to restart the application (or at least the current activity) after opting in.
-
isOptedOut
static boolean isOptedOut(@NonNull() Context context)
Returns whether Batch has been opted out from or not
Warning: This method might perform some quick I/O in the caller thread.
-
setFindMyInstallationEnabled
static void setFindMyInstallationEnabled(boolean enabled)
Control whether Batch should enables the Find My Installation feature (default = true)
If enabled Batch will copy the current installation id in the clipboard when the applicationis foregrounded 5 times within 12 seconds.
- Parameters:
enabled- Whether to enable the find my installation feature.
-
onCreate
static void onCreate(Activity activity)
Method to call on your main activity onCreate.
- Parameters:
activity- Created activity
-
onStart
static void onStart(Activity activity)
Method to call on your main activity onStart to start Batch and support URL scheme events.You must call this method before any other on Batch.Will fail and log an Error if
- Given
{@code activity}is null - You call it before calling start
- Your app doesn't have
{@code android.permission.INTERNET}permission
- Parameters:
activity- The activity that's starting
- Given
-
onServiceCreate
static void onServiceCreate(Context context, boolean userActivity)
Method to call on your service onCreate to start Batch.You must call this method before any other on Batch.Note that all Batch functionality is not available in this mode. See the documentation for more info.Using this method, you'll also be able to control whether this start should count as user activity or not.This might impact Analytics.Will fail and log an Error if
- Given
{@code context}is null - You call it before calling start
- Your app doesn't have
{@code android.permission.INTERNET}permission
- Parameters:
context- The service or application contextuserActivity- If the start comes from user activity or for background use only
- Given
-
onServiceDestroy
static void onServiceDestroy(Context context)
Method to call on your service onDestroy to stop Batch.Calling this method if Batch is already stopped or not started will do nothing
- Parameters:
context- The service or application context
-
onNewIntent
static void onNewIntent(Activity activity, Intent intent)
Method to call on your main activity onNewIntentCalling this method if Batch is already stopped or not started will do nothing
- Parameters:
intent- Android's intent
-
onStop
static void onStop(Activity activity)
Method to call on your main activity onStopCalling this method if Batch is already stopped or not started will do nothing
- Parameters:
activity- the activity that generate the onStop event
-
-
-
-