Package com.batch.android
Class Batch.Actions
- java.lang.Object
-
- com.batch.android.Batch.Actions
-
- Enclosing class:
- Batch
public static final class Batch.Actions extends java.lang.ObjectBatch Action manager
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddDrawableAlias(java.lang.String alias, int drawableID)Add an alias to a drawable that can be referenced remotely.static booleanperformAction(android.content.Context context, java.lang.String actionIdentifier, JSONObject arguments)Perform an action by its identifier.static voidregister(UserAction userAction)Register an action with Batch.static voidsetDeeplinkInterceptor(BatchDeeplinkInterceptor interceptor)Set a deeplink interceptor.static voidunregister(java.lang.String identifier)Unregister an action from Batch.
-
-
-
Method Detail
-
register
public static void register(@NonNull UserAction userAction)Register an action with Batch.
If an action already exists for that identifier, it will be replaced. Identifiers are not case-sensitive. Note that the action identifier cannot start with "batch.", as they are reserved by the SDK. Trying to register such an action will throw an exception.- Parameters:
userAction- The action to register
-
unregister
public static void unregister(@NonNull java.lang.String identifier)Unregister an action from Batch.
Trying to unregister an action that has not be unregistered will silently fail. Note that trying to unregister an action that starts with "batch." will throw an exception.- Parameters:
identifier- The action identifier. Identifiers are not case-sensitive.
-
addDrawableAlias
public static void addDrawableAlias(@NonNull java.lang.String alias, @DrawableRes int drawableID)Add an alias to a drawable that can be referenced remotely.
This is used for CTAs (buttons) showing in the push notifications themselves. While you can directly set a drawable resource when making your notification, it is recommended that you add a set of aliases. That way, you can change the drawable file name between versions without having to think about that when pushing different versions of your applications. You can also use aliases to make the icon names more readable or useful to anybody sending notifications to your app.
Note that since Android N, notifications with button will not display icons anymore.- Parameters:
alias- Drawable alias. Not case sensitivedrawableID- Drawable resource ID to use
-
performAction
public static boolean performAction(@NonNull android.content.Context context, @NonNull java.lang.String actionIdentifier, @Nullable JSONObject arguments)Perform an action by its identifier.
Note: The action will have a null source.- Parameters:
actionIdentifier- Action identifier. Batch internal actions cannot be called using this method.arguments- Action arguments. Optional.- Returns:
- true if an action was registered for this identifier and performed, false otherwise.
-
setDeeplinkInterceptor
public static void setDeeplinkInterceptor(@Nullable BatchDeeplinkInterceptor interceptor)Set a deeplink interceptor. It allows you to tweak how Batch will open your activity.- Parameters:
interceptor- ABatchDeeplinkInterceptorinterface. Null to remove a previously set one.
-
-