Action

abstract class Action

The base action class that describes an operation to perform.

An action is an abstraction over a unary function, which takes com.urbanairship.actions.ActionArguments and performs a defined task, producing an optional com.urbanairship.actions.ActionResult. Actions may restrict or vary the work they perform depending on the arguments they receive, which may include type introspection and runtime context.

In the larger view, the Actions framework provides a convenient way to automatically perform tasks by name in response to push notifications, Rich App Page interactions and JavaScript.

The UA library comes with pre-made actions for common tasks such as setting tags and opening URLs out of the box, but this class can also be extended to enable custom app behaviors and engagement experiences.

While actions can be run manually, typically they are associated with names in the com.urbanairship.actions.ActionRegistry, and run on their own threads with the com.urbanairship.actions.ActionRunRequest.

Actions that are either long lived or are unable to be interrupted by the device going to sleep should request a wake lock before performing. This is especially important for actions that are performing in SITUATION_PUSH_RECEIVED, when a push is delivered when the device is not active.

The value returned by shouldRunOnMainThread determines which thread should run the action if executed asynchronously. If an action involves a UI interaction, this method should be overridden to return true so that the action definitely runs before the app state changes.

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
annotation class Situation

Properties

Link copied to clipboard
Situation where an action is triggered from Action Automation.
Situation where an action is triggered from a background notification action button.
Situation where an action is triggered from a foreground notification action button.
Link copied to clipboard
Situation where an action is manually invoked.
Link copied to clipboard
Situation where an action is triggered when a push is opened.
Link copied to clipboard
Situation where an action is triggered when a push is received.
Link copied to clipboard
Situation where an action is triggered from a web view.

Functions

Link copied to clipboard
Called before an action is performed to determine if the the action can accept the arguments.
Link copied to clipboard
open fun onFinish(@NonNull arguments: ActionArguments, @NonNull result: ActionResult)
Called after the action performs.
Link copied to clipboard
open fun onStart(@NonNull arguments: ActionArguments)
Called before an action is performed.
Link copied to clipboard
abstract fun perform(@NonNull arguments: ActionArguments): ActionResult
Performs the action.
Link copied to clipboard
Determines which thread runs the action.