Configuration

Android permissions configuration

The Yoco SDK requires the following permissions to be declared in your AndroidManifest.xml file to function correctly.

PermissionPurposeDescription
android.permission.ACCESS_COARSE_LOCATIONLocationRequired for transaction security and Bluetooth scanning.
android.permission.ACCESS_FINE_LOCATIONLocationRequired for transaction security and Bluetooth scanning.
android.permission.ACCESS_NETWORK_STATENetworkRequired for checking network availability before communication.
android.permission.ACCESS_WIFI_STATENetworkRequired for checking Wi-Fi status for robust data transfer.
android.permission.BLUETOOTHBluetoothRequired for connecting to terminals (for older Android versions).
android.permission.BLUETOOTH_ADMINBluetoothRequired for managing terminal state changes (for older Android versions).
android.permission.BLUETOOTH_CONNECTBluetoothRequired for connecting to Yoco card terminals.
android.permission.BLUETOOTH_SCANBluetoothRequired for scanning for nearby Yoco card terminals.
android.permission.INTERNETNetworkRequired for sending/receiving transaction data to/from Yoco servers.
android.permission.READ_PHONE_STATEDiagnostics (Optional)Can be used to improve network diagnostics.
android.permission.WAKE_LOCKProcessingRequired to keep the CPU awake during a transaction to prevent interruption.

Runtime permission requests must be handled for BLUETOOTH_CONNECT, BLUETOOTH_SCAN, and ACCESS_FINE_LOCATION on Android 12 (API 31) and higher.

Initialising the YocoSDK

Initialise the YocoSDK in your Application subclass to allow the SDK to set up everything it needs to run properly.

1import com.yoco.payments.sdk.YocoSDK
2
3class SampleApplication : Application() {
4 override fun onCreate() {
5 super.onCreate()
6 initialiseSdk()
7 }
8
9 fun initialiseSdk() {
10 // Initialises Yoco Payment UI SDK
11 YocoSDK.initialise(
12 context = applicationContext
13 )
14 }
15}

The YocoSDK should only be initialised ONCE per application lifecycle.

Configuring the YocoSDK

After the YocoSDK is initialised, its dynamic parameters can be configured. This method can be called multiple times and from any location within your application.

To configure the YocoSDK, you will need to use the SDK integration secret.

1import com.yoco.payments.sdk.data.enums.SDKEnvironment
2
3// Configures the YocoSDK
4YocoSDK.configure(
5 context = context,
6 secret = "<integration secret>",
7 environment = SDKEnvironment.PRODUCTION,
8 //optional: defaults to false
9 enableLogging = true
10)

Optionally, integrators have the choice to implement a seamless login experience by passing both the business API token and the SDK integration secret.

1import com.yoco.payments.sdk.data.enums.SDKEnvironment
2
3// Configures the YocoSDK
4YocoSDK.configure(
5 context = context,
6 secret = "<integration secret>",
7 apiToken = "<business api token>",
8 environment = SDKEnvironment.PRODUCTION,
9 //optional: defaults to false
10 enableLogging = true
11)