Resetting the POS
You use the reset operation to clear all application data, configurations, and active sessions within the Tap on Phone application.
You must perform a reset when you want to switch to a different user or merchant. You can also use a reset to force the application to refresh its configuration. After a successful reset, the application returns to a None state, and you must re-initialize it before processing any new transactions.
Step 1: Register a Broadcast Receiver
Like the status request, the reset operation occurs in the background. You must register a BroadcastReceiver to know when the Tap on Phone application finishes the reset process.
You can listen for the default response action (com.dejamobile.cbp.sps.RESET_BROADCAST_RESPONSE) or define your own custom action.
// Define your broadcast action (default or custom)
val resetResponseAction = "com.dejamobile.cbp.sps.RESET_BROADCAST_RESPONSE"
val receiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
println("The Tap on Phone application has been successfully reset.")
// The POS is now in a "None" state. You must initialize it again.
// Unregister the receiver once handled
context?.unregisterReceiver(this)
}
}
// Register the receiver
val filter = IntentFilter(resetResponseAction)
registerReceiver(receiver, filter)The reset response broadcast does not contain any intent extras. Receiving the broadcast confirms that the reset process is complete.
Step 2: Send the Reset Broadcast
Construct and send the broadcast intent to trigger the reset. You must target the ResetBroadcastReceiver class within the Tap on Phone application.
val intent = Intent().apply {
action = "com.dejamobile.cbp.sps.RESET_BROADCAST"
component = ComponentName(
"com.dejamobile.cbp.sps.app",
"com.dejamobile.cbp.sps.app.broadcast.ResetBroadcastReceiver"
)
addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
// Optional: Specify your custom response action
// putExtra("ResponseAction", resetResponseAction)
}
// Send the broadcast
sendBroadcast(intent)Next Steps
After resetting the POS, you cannot perform any transactions until you initialize the application again with a valid user and merchant.
- Refer to Quick Start: Your First Initialization to initialize the application for the new user.
- Learn how to process payments in Process a Purchase Transaction.