SDK Initialization
Initializing PensaSdk
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.
Call
PensaSdk.initPensa()withPensaConfiguration.Builder()inside theonCreate()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") }
)
}
}If this function is not invoked in the application's Application class, an exception will be thrown.
setClientId() and setClientSecret() must be provided in PensaConfiguration.Build()
If either of them is missing, .build() will throw an exception.
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?