How to correctly set up custom events?

What is the correct procedure to set up and register custom events for the Android platform.

I have been through the documentation repeatedly - however cannot see a simple straightforward example of how to do this. 


What I need:

From clicking a notification, i need to be able to distinguish between 3 scenarios - that need to perform different actions

- The 3 scenarios are:

    1. Simple deep link message sent that contains a URI - based on the URI - the user will be taken to either of two different Activities (screens)

    2. An inbox message sent ,that when the notification is received - the user clicks on it - and the Inbox message opens directly into a default browser, displaying the html/css

    3. A push message that contains some data - that when the user clicks on the notification - the user will be taken to different Activities (screens), based on that data


What I have:

In trying to follow the documentation, and sample app, I have created 3 classes that subclass the Action class 

One example

public class InboxMessageCustomAction extends Action {

public static final String DEFAULT_REGISTRY_NAME = "open_mc_action";

* Default registry short name
public static final String DEFAULT_REGISTRY_SHORT_NAME = "^mc";

public static final String MESSAGE_ID_PLACEHOLDER = "auto";

public boolean acceptsArguments(@NonNull ActionArguments arguments) {
switch (arguments.getSituation()) {
return true;

return false;

public ActionResult perform(@NonNull ActionArguments arguments) {

String messageId = arguments.getValue().getString();

if (MESSAGE_ID_PLACEHOLDER.equalsIgnoreCase(messageId)) {
PushMessage pushMessage = arguments.getMetadata().getParcelable(ActionArguments.PUSH_MESSAGE_METADATA);
if (pushMessage != null && pushMessage.getRichPushMessageId() != null) {
messageId = pushMessage.getRichPushMessageId();
} else if (arguments.getMetadata().containsKey(ActionArguments.RICH_PUSH_ID_METADATA)) {
messageId = arguments.getMetadata().getString(ActionArguments.RICH_PUSH_ID_METADATA);
} else {
messageId = null;

if (UAStringUtil.isEmpty(messageId)) {
} else {

return ActionResult.newEmptyResult();

public boolean shouldRunOnMainThread() {
return true;


In my launch Activity I have a method that monitors the registration of these Actions


public class ActionMonitor {

public ActionMonitor() { }

public void start() {

InboxMessageCustomAction inboxMessageCustomAction = new InboxMessageCustomAction();
CustomSpecialMessageAction specialMessageAction = new CustomSpecialMessageAction();
DeepLinkCustomAction deepLinkCustomAction = new DeepLinkCustomAction();

ActionRegistry registry = UAirship.shared().getActionRegistry();






And have set up the auto takeoff by registering in the AndroidManifest that references this class:


public class UASetup extends Autopilot {

public void onAirshipReady(@NonNull UAirship airship) {

PushManager pushManager = UA.getPushManager();
String channelId = pushManager.getChannelId();

.registerAction(new CustomSpecialMessageAction(), "special_message_action");

.registerAction(new DeepLinkCustomAction(), "deep_link_action");

.registerAction(new InboxMessageCustomAction(), "inbox_message_custom_action");

Timber.d("Urban airship channel id %s",channelId);

public AirshipConfigOptions createAirshipConfigOptions(@NonNull Context context) {
AirshipConfigOptions options = new AirshipConfigOptions.Builder()
.setFcmSenderId("000000000000") // FCM/GCM sender ID

return options;

What I want

What i want to know is, am i missing any steps. Also - how do I distinguish between these 3 notifications. For instance if users click on a notification - it could be any of the three - but they all have different actions to perform.


I hope I am explaining myself correctly. Any help would be appreciated 


Many thanks




Didn't find what you were looking for?

New post


1 comment

  • Hi Paul,

    I think we can probably simplify a lot of this, given the scenarios you listed out.

    The 1st and 3rd scenario you listed out sound like you may just want to set up Deeplinks within your app such that the app can determine which activity to display to the user when the push is tapped on.

    For those, you may consider looking at our Android Deeplinking guide as we describe exactly that. This will entail creating a ParseDeepLink Activity that gets called when a push is tapped on and will parse the deeplink in the push and navigate the user to the appropriate activity.


    Now, for the Message Center scenario, you don't need to handle this at all, since that functionality is actually how the Message Center works out-of-the-box! That is, the UA SDK knows when a Message Center message is attached to a push notification. When the user taps on the push, we'll navigate the user to the app and display the Message Center message to the user in a webview.


    Also, you may wish to look at our Android Sample for the deeplinking examples.

    Let me know if that helps!


Please sign in to leave a comment.