SDK Initialization
Initializing the Pensa SDK is straightforward. Follow the steps below to set up the SDK with your credentials and start using its features.
1- Initializing PensaSdk
Call initPensa() at the startup of your app, preferably in the initState of your root widget.
import 'package:pensa_flutter_sdk/pensa_flutter_sdk.dart';
final pensa = PensaFlutterSdk();
await pensa.initPensa(
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
isLoggingEnabled: true,
);
```clientIdandclientSecretare required.If
clientIdorclientSecretis missing, initialization will fail.isLoggingEnabledis optional. When true, internal SDK logs will be printed to console.
2- Add Listeners (Optional)
Each event delivered by the pensa_flutter_sdk_events channel includes two parts:
event: The event name (one of the supported values).payload: A map containing the event-specific data.
onScanUploadProgressUpdate
tdlinxId, scanAreaId, progress
onScanUploadCompleted
tdlinxId, scanAreaId
onScanUploadFailed
tdlinxId, scanAreaId, error
onCantScanReported
tdlinxId, scanAreaId, reason
To listen to SDK events such as upload progress, success, or failure, you can create a helper hook like below:
You should call usePensaListeners() before initPensa(). Calling it after may result in missing early events emitted during SDK initialization.
This will automatically register and clean up all supported event listeners.
Once initialized, you can use any of the SDK methods like showShelfScans, showStoresScreen, or showScanArea.
showShelfScans, showStoresScreen, or showScanArea.Last updated
Was this helpful?