Actions for the Cordova Plugin

Airship Actions provide a convenient way to automatically perform tasks by name in response to push notifications, Message Center App Page interactions, and JavaScript.

An action describes a function, which takes an optional argument and performs a predefined task, producing an optional result. Actions may restrict or vary the work they perform depending on the arguments they receive, which may include type introspection and runtime context.

The Airship SDK includes built-in actions for common tasks, and you can create custom actions to extend functionality.

For a complete list of available built-in actions, see the Actions User Guide.

Running Actions

You can run actions programmatically using the Airship.actions.run() method. The action value can be a string, number, boolean, null, object, or array.

Running an action
// Run an action with a string value
Airship.actions.run("action_name", "action_value", 
    function(result) {
        // Action completed successfully
        console.log("Action result:", result);
    },
    function(error) {
        // Action failed
        console.error("Action error:", error);
    }
);

// Run an action with an object value
Airship.actions.run("action_name", {
    key: "value",
    number: 42
}, 
    function(result) {
        console.log("Action result:", result);
    }
);

// Run an action without a value
Airship.actions.run("action_name", null, 
    function(result) {
        console.log("Action result:", result);
    }
);