Documentation / MRZ Scanner 1.x (archive) / Xamarin
Android
1.Copy MRZScannerDroidBinding.dll in the root folder of your project (MRZScannerAndroid\MRZScannerAndroid in our case)
2.Add reference to MRZScannerDroidBinding.dll file in your project references
3.Add the following code to the layout.xml of the activity where you want the scanner to be shown:
(it is recommended that the scanner takes full screen)
<fragment
android:id="@+id/scannerFragment"
android:name="com.scansolutions.mrzscannerlib.MRZScanner"
android:layout_width="match_parent"
android:layout_height="match_parent" />
4.Use this code to configure the scanner. The code should be added in the activity where the scanning will take place
MRZScanner mrzScanner =(MRZScanner)SupportFragmentManager.FindFragmentById(Resource.Id.scannerFragment);
mrzScanner.SetScannerType(ScannerType.ScannerTypeMrz); // Options: [ScannerTypeMrz, ScannerTypeDocImageId, ScannerTypeDocImagePassport]
MRZScanner.SetIDActive(true); // Enable/disable the ID document type
MRZScanner.SetPassportActive(true); // Enable/disable the Passport document type
MRZScanner.SetVisaActive(true); // Enable/disable the Visa document type
MRZScanner.SetMaxThreads(2); // Set the max CPU threads that the scanner can use
MRZScanner.RegisterWithLicenseKey(this, "licenseKey");
string sdkVersion = MRZScanner.SdkVersion(); // Get the current SDK version of MRZScanner
5.Implement the IMRZScannerListener interface as a listener for a successful MRZ scan:
public class MainActivity : AppCompatActivity, IMRZScannerListener
{
.......
iOS
1.Copy MRZScanneriOSBinding.dll in the root folder of your project (MRZScanneriOS\MRZScanneriOS in our case)
2.Add reference to MRZScanneriOSBinding.dll file in your project references
3.Start the scanner with the following code:
MRZScannerController mrzScannerController = new MRZScannerController();
MRZScannerController.RegisterLicenseWithKey("license_key");
mrzScannerController.WeakDelegate = this;
UIViewController currentViewController = NavigationController;
if (currentViewController == null)
currentViewController = this;
currentViewController.AddChildViewController(mrzScannerController);
mrzScannerController.InitUI(currentViewController);
4.To get the result, implement the IMRZScannerDelegate:
public partial class ViewController : UIViewController, IMRZScannerDelegate { ...
Export("successfulScanWithResult:")]
public void SuccessfulScanWithResult(MRZResultDataModel mrzResultDataModel) { ...
5.Add the following row in your Info.plist file:
key: NSCameraUsageDescription
value: MRZ Scanner requires using camera
Updated May 19, 2020 · Questions? Ask us