Detecting SDK Dismissal Events
Detecting SDK Dismissal Events (Back Tap or Completion)
Once the Nashid Verify SDK flow begins via the verify(ofType:) function, you may want to track how the user exits the SDK — whether by tapping the back button or completing verification. This can be useful for logging, analytics, or custom handling in your host app.
To support this, the SDK provides a delegate method that is called when the SDK is dismissed. The method includes an VerifySDKExitStep
enum, allowing you to distinguish between user-initiated exits and successful verification completions.
Android:
import nashid.verify.sdk.model.VerifySDKCallback
import nashid.verify.sdk.model.VerifySDKExitStep
class MainActivity : AppCompatActivity(), VerifySDKCallback {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Set callback before initialization
VerifySDKManager.getInstance().setCallback(this)
// Then initialize SDK
initializeSDK()
}
override fun onSDKExit(exitStep: VerifySDKExitStep) {
when (exitStep) {
VerifySDKExitStep.OcrCancelled -> {
// Handle document scanning cancellation
Toast.makeText(this, "Document scanning cancelled", Toast.LENGTH_SHORT).show()
}
VerifySDKExitStep.NfcCancelled -> {
// Handle NFC scanning cancellation
Toast.makeText(this, "NFC scanning cancelled", Toast.LENGTH_SHORT).show()
}
VerifySDKExitStep.LivenessCancelled -> {
// Handle liveness check cancellation
Toast.makeText(this, "Liveness check cancelled", Toast.LENGTH_SHORT).show()
}
VerifySDKExitStep.Completed -> {
// Handle successful completion
Toast.makeText(this, "Verification completed!", Toast.LENGTH_SHORT).show()
}
}
}
}
iOS:
- Define and Assign the Delegate
In your host view controller, conform to the VerifySDKDelegate protocol and assign it before calling verify():
VerifySDKManager.shared.delegate = self
VerifySDKDelegate methods
func verifySDKDidFinish(with existStep: NewVerifySDK.VerifySDKExitStep)
- Understand the Exit Reasons
The SDK will notify your delegate with one of the following VerifySDKExitStep
values:
- .ocrCancelled – The user tapped the back button exited the SDK.
- .nfcCancelled – The user tapped the back button exited the SDK.
- .livenessCancelled – The user tapped the back button exited the SDK.
- .completed – The verification flow completed successfully.
Important: Always set the delegate before presenting the SDK flow to ensure you receive dismissal events.
Flutter:
The Nashid Verify SDK provides a stream of exit events that notify you when the user cancels or completes a verification step (e.g., OcrCancelled, NfcCancelled, LivenessCancelled, or Completed). This is useful for handling user exits or cancellations in your Flutter app UI.
final subscription = _nashidIoPlugin.exitEvents.listen((event) {
// event will be one of: 'OcrCancelled', 'NfcCancelled', 'LivenessCancelled' or 'Completed'
if (event == 'OcrCancelled') {
// Handle document scanning cancellation
} else if (event == 'NfcCancelled') {
// Handle NFC scanning cancellation
} else if (event == 'LivenessCancelled') {
// Handle liveness check cancellation
} else if (event == 'Completed') {
// Handle successful completion
}
});
// To stop listening:
// subscription.cancel();
```
Note:
- Always cancel the subscription when you no longer need to listen (e.g., in dispose).
React Native:
The Nashid Verify SDK provides a stream of exit events that notify you when the user cancels or completes a verification step (e.g., `OcrCancelled`, `NfcCancelled`, `LivenessCancelled`, or `Completed`). This is useful for handling user exits or cancellations in your React Native app UI.
**How to use:**
```tsx
import { useEffect } from 'react';
import { Alert, NativeEventEmitter, NativeModules } from 'react-native';
useEffect(() => {
// Initialize the SDK event emitter
const { NashIdVerifySdk } = NativeModules;
const sdkEmitter = new NativeEventEmitter(NashIdVerifySdk);
// Start listening for 'onSDKExit' events
const subscription = sdkEmitter.addListener('onSDKExit', (event) => {
// event.exitStep will be one of: 'OcrCancelled', 'NfcCancelled', 'LivenessCancelled', 'Completed', or other custom values
const exitStep = event.exitStep;
if (exitStep === 'OcrCancelled') {
// Handle document scanning cancellation
} else if (exitStep === 'NfcCancelled') {
// Handle NFC scanning cancellation
} else if (exitStep === 'LivenessCancelled') {
// Handle liveness check cancellation
} else if (exitStep === 'Completed') {
// Handle successful completion
} else {
// Handle unknown or unexpected exit step
}
// Optionally show an alert with the exit status
Alert.alert('SDK Exit', `Verification exited with step: ${exitStep}`);
});
// To stop listening:
return () => {
subscription.remove();
};
}, []);
```
Last updated on July 30, 2025