Platform Docs

Using Customer-Facing Platform

Customer-Facing Platform (CFP) Activities

Custom Activities are Android activities installed on the Clover Mini that your POS can start while the Mini is tethered in customer-facing mode through USB Pay Display, Secure Network Pay Display, or Cloud Pay Display. Your POS can start and communicate with Custom Activities using CloverConnector’s startCustomActivity() and sendMessageToActivity() methods. The POS can receive messages or a result through the onMessageFromActivity() and onCustomActivityResult() methods.

Clover CFP SDK

The clover-cfp-sdk provides a base implementation of an Activity. You can extend it to facilitate setting result values, as well as sending and receiving string messages between the POS and Custom Activity.

Defining Custom Activities

Custom Activities must have the category com.clover.cfp.ACTIVITY:

<activity android:name="com.clover.cfp.examples.BasicExampleActivity"
         android:launchMode="singleTop"
         android:noHistory="true"
         android:windowSoftInputMode="adjustPan"
         android:label="@string/title_activity_basic_example" >
   <intent-filter>
       <action android:name="com.clover.cfp.examples.BasicExample"/>
       <category android:name="com.clover.cfp.ACTIVITY"/>
       <category android:name="android.intent.category.DEFAULT" />
   </intent-filter>
</activity>

Starting Custom Activities and getting Activity results

Applications can only start Custom Activities when the Clover Mini is in an idle state (at the Welcome, Display Order, or Thank You screen, for example).

You can start Custom Activities as blocking (default) or non-blocking.

  • Blocking Activities will prevent other Activities from starting until the Custom Activity is finished, or until resetDevice() is called. This mode may be useful when a customer is entering or selecting information, and shouldn’t be interrupted by other POS activities.
  • Non-blocking Activities will finish and be replaced when the POS makes a new Activity request. For example, they can be useful if a Custom Activity is displaying a custom order screen that should be replaced when a payment is requested.

You can make Custom Activities return a payload to the POS by setting the string extra com.clover.remote.terminal.remotecontrol.extra.EXTRA_PAYLOAD on the result Intent. The Clover device will pass the string back as the payload attribute for the CustomActivityResponse object that is passed into the onCustomActivityResponse() callback.

cloverConnector.startCustomActivity("com.clover.cfp.examples.BasicExample", payload: "{'name':'John Smith'}")
class BasicExampleActivity extends CustomCFPActivity {
     @Override protected void onCreate(Bundle savedInstanceState) {
     {
           String payload = getIntent().getStringExtra(EXTRA_PAYLOAD);
     }
}

NOTE

The CloverCFPActivity class has a convenience method setResultAndFinish(int resultCode, String payload).

Communicating with Custom Activities

Your POS can communicate with a running Custom Activity through string messages. For example, sendMessageToActivity() passes a string payload to the appropriate Activity, based on the Activity’s action name. The Custom Activity can receive the message by overriding the onMessage(String payload) method defined in the CustomCFPActivity class.

To send a message from a Custom Activity to the POS, the Custom Activity can call sendMessage(String payload), which is defined in CustomCFPActivity. The POS will receive the message in the onMessageFromActivity() callback defined in the ICloverConnectorListener class.

let msgRequest = MessageToActivity("com.clover.cfp.examples.BasicActivity", payload:"{'title':'Specials', ‘message’:’Enjoy these menu items for half price!’")
cloverConnector.sendMessageToActivity(msgRequest)
class BasicExampleActivity extends CustomCFPActivity {
     protected abstract void onMessage(String payload) {
          // handle message
     }
     private void doSomething() {
          sendMessage({‘status’:’PROCESSING’});
     }
}

Finishing Custom Activities

A Custom Activity that started as a blocking Activity must be finished either by the Activity, or through a resetDevice() call from the POS. The finish() or setResultAndFinish(int result, String payload) method can be triggered from the Activity (i.e., a button tap), or by sending a message to the Activity to trigger a finish() call.

A Custom Activity that starts as a non-blocking Activity can be finished by the Activity, by a resetDevice() call from the POS, or by starting another Activity. The other Activity can either be explicit (e.g., startCustomActivity()), or implicit to Clover Connector (e.g., sale()).

Custom Activity interaction


Using Customer-Facing Platform


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.