Set up broadcasts and intents

United States
Canada
Europe
Latin America

The Clover platform uses the Android Intents system to allow third-party apps to integrate more deeply with Clover's base activities. These intents fall under three categories of usage:

  • Clover Activity intents - Used by your app to launch basic Clover activities with Android's startActivity() method.

  • Clover broadcasts - Broadcasts initiated by Clover apps when certain events occur. Your app may react to these broadcasts.

  • Action intents - Set as the action for your activity's intent filter, giving merchants the option to launch your app from the transaction flow.

For more information, see the documentation for Clover's public intents.

Clover Activity intents

These intents can be used with the startActivity() and startActivityForResult() methods to launch one of the Activities of a core Clover app, allowing you to pass responsibility for certain functionality to the base Clover workflow. Extras can be passed along with these intents with additional data and options.

Example

The ACTION_START_REGISTER intent launches the base register activity. You can also use this intent to pass an order ID or customerJson object that will be associated with the Register session.

Intent intent = new Intent(Intents.ACTION_START_REGISTER);
intent.putExtra(Intents.EXTRA_ORDER_ID, "PTEXTPYDZ6K4C");
startActivity(intent);

OR

Intent intent = new Intent(Intents.ACTION_START_REGISTER);
String customerJson = "{'id': 'MDGRBQZN6C9V0', 'emailAddresses': [{'id': '2JVY19VDH9SAW','emailAddress': '[email protected]'}]}";
intent.putExtra(EXTRA_CUSTOMER_V3, customerJson);
startActivity(intent);

Additional Examples

The following examples demonstrate how to use Clover Activity intents.

Clover broadcasts

Clover emits broadcasts when important events occur, such as when a new order or payment is created. Your application can register a broadcast receiver in order to listen and respond to these events.

Example

Setting a listener for the ACTION_ORDER_CREATED intent will trigger your app whenever an order is created. Your app will receive the ID for the new order.

public class MyReceiver extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (action.equals(Intents.ACTION_ORDER_CREATED)) {
      String orderId = intent.getStringExtra(Intents.EXTRA_CLOVER_ORDER_ID);
    }
  }
}

Additional Examples

The following examples demonstrate how to use Clover broadcasts:

Action intents

If you set an Action intent as the action for your activity's intent filter, the Clover system apps will register your app as a listener for that intent. Typically this relationship will be used by one or more of the Clover base apps to interface with your app's activity. For instance, the following code snippet registers an activity as a listener for the ACTION_MODIFY_ORDER intent, meaning that the merchant-facing payment screen will display a button with your label value that will launch your activity, passing the ID of the order to be modified.

Example

The ACTION_MODIFY_ORDER intent will allow your app to slot into the standard Clover payment flow and work with an order before passing it back to Clover for finalization and payment.

<!--In AndroidManifest.xml Application-->

<activity
    android:name=".ModifyOrderActivity"
    android:label="@string/title_activity_modify_order">
    <intent-filter>
        <action android:name="clover.intent.action.MODIFY_ORDER"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>
// In ModifyOrderActivity onCreate()

String orderId = getIntent().getStringExtra(Intents.EXTRA_ORDER_ID);

Additional Examples

The following examples demonstrate how to use Action intents.