initializeManually

@JvmStatic
@JvmName(name = "initializeManually")
suspend fun initializeManually(context: Context): InitializationState

Triggers manual initialization of the SDK and waits for it to complete.

This suspend function should only be used if automatic initialization has been disabled.

Important: The SDK requires the application to be in the foreground to bind to the payment service. It is recommended to call this method when the Activity is in the RESUMED state.

Example (Modern Approach)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.RESUMED) {
val state = InPersonPaymentsTools.initializeManually(this@MainActivity)
if (state is InitializationState.SuccessfulInitialization) {
// SDK is ready.
}
}
}
}

Example (Legacy Approach)

override fun onResume() {
super.onResume()

lifecycleScope.launch {
val state = InPersonPaymentsTools.initializeManually(this@MainActivity)
// ...
}
}

Parameters

context

The application context.

See also