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 the Clover base activities. These intents fall under three categories of usage:

Android Intents and their usage
Clover Activity intentsUsed by your app to launch basic Clover activities with the Android startActivity() method.
Clover broadcastsBroadcasts are initiated by Clover apps when certain events occur. Your app may react to these broadcasts.
Action intentsSet 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 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 show 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 app can register a broadcast receiver to listen to 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 show 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 is used by one or more of the Clover base apps to interface with your app's activity. Example:, 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 let your app 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 show how to use Action intents.