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 a root file like index.js before calling AppRegistry.registerComponent.
import {initPensa} from 'pensa-sdk-react-native';
initPensa({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
isLoggingEnabled: true,
})
.then(() => {
console.log('[Pensa] SDK init success');
})
.catch((error) => {
console.log('[Pensa] SDK init error:', error);
});clientIdandclientSecretare required.If
clientIdorclientSecretis missing, initialization will fail.isLoggingEnabledis optional. When true, internal SDK logs will be printed to console.
2- Add Listeners (Optional)
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:
Then call the hook in your component:
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?