EnumErrorCode
EnumErrorCode is an enumeration that defines the error codes owned by the MRZ Scanner bundle. These are reported through ErrorCode alongside a result status of EnumResultStatus.Exception.
Definition
Assembly: Dynamsoft.MRZScannerBundle.Maui
Namespace: Dynamsoft.MRZScannerBundle.Maui
public enum EnumErrorCode
{
CameraPermissionDenied = 1001,
CameraPermissionRestricted = 1002
}
Members
| Member | Value | Description |
|---|---|---|
CameraPermissionDenied |
1001 | The user denied camera access but can grant it in Settings (on Android, also through a new in-app request). |
CameraPermissionRestricted |
1002 | Device policy withholds camera access (for example Screen Time, parental controls or MDM), and the user can’t grant it. |
ErrorCode is an int, so compare it with a cast:
if (result.ErrorCode == (int)EnumErrorCode.CameraPermissionDenied)
{
// Offer a route into the app's settings page.
}
Remarks
- Not an exhaustive list. Capture Vision errors use the same property with codes less than
0. The bundle’s own codes are1000–1999. - The codes differ by remedy. For
CameraPermissionDenied, offer a route into the app’s settings. ForCameraPermissionRestricted, explain the restriction instead: Settings has no camera toggle in that state. - Handling them is optional. By default the scanner shows its own alert or dialog first. Set
IsCameraPermissionPromptEnabledtofalseonly to present your own UI; the denial is reported either way.
The codes are the same on Android and iOS. The
ErrorStringwording comes from each platform’s scanner and can differ.
Errors reported by the MAUI layer
Failures in the MAUI layer have no native code. They’re reported as EnumResultStatus.Exception with an ErrorCode of 0, and ErrorString gives the reason. They occur when:
- Android: the app has no activity to launch the scanner from, or the scanner closes without a result.
- iOS: the app has no page on screen to present the scanner from, or another page is still animating (see Starting the Scanner from a Modal Page).
Recovering from a denial
- iOS asks for camera access only once per install. After a denial, the scanner’s alert offers Open Settings, and changing the permission there terminates the app. The next scan after relaunch picks up the new setting, so keep your own route into Settings on the page that shows the denial, for example with
AppInfo.ShowSettingsUI(). - Android recovers in place: the app keeps running after the permission is granted in Settings, and the next scan uses it.
The ScanMRZ Demo App shows an Open Settings button only for CameraPermissionDenied.