SDK Initialization

Initializing PensaSdk

  1. Extend the Application class: Create a custom Application class in your app, or use your existing one. This class serves as the entry point for configuring the SDK.

  2. Call PensaSdk.initPensa() with PensaConfiguration.Builder() inside the onCreate() method, as shown below:

import android.app.Application
import com.pensasystems.pensasdk.PensaSdk
import com.pensasystems.pensasdk.PensaConfiguration

class MyApp : Application() {

    override fun onCreate() {
        super.onCreate()

        val config = PensaConfiguration.Builder()
            .setClientId("YOUR_CLIENT_ID")
            .setClientSecret("YOUR_CLIENT_SECRET")
            .build()

        PensaSdk.initPensa(
            applicationContext = this,
            configuration = config,
            onSuccess = { println("Pensa SDK is ready to start!!") },
            onError = { println("Error initializing SDK: $it") }
        )
    }
}

Logging

You can show/hide Pensa framework logs by simply calling the .enableLogging(true) or .enableLogging(false) within PensaConfiguration.Builder() . By default the Pensa library logs are disabled.

Listeners

To receive real-time updates from the SDK, you can assign custom listeners using the set listener methods inside PensaConfiguration.Builder().

Listener List

  • .setScanUploadListener()

    • Track scan upload progress via onScanUploadProgressUpdate()

    • Get notified when a scan upload is completed successfully via onScanUploadCompleted()

    • Get notified when a scan upload is failed via onScanUploadFailed()

  • .setCantScanEventListener()

    • Handle situations where a scan cannot be performed via onCantScanReported()

Last updated

Was this helpful?