Esempio n. 1
0
        public void DidFindResult(ALIDScanPlugin anylineIDScanPlugin, ALIDResult scanResult)
        {
            ALMRZIdentification identification = (ALMRZIdentification)scanResult.Result;
            string passportNumber = identification.DocumentNumber.Trim();
            NSDate dateOfBirth    = identification.DateOfBirthObject;
            NSDate dateOfExpiry   = identification.DateOfExpiryObject;
            //The passport number passed to the NFC chip must have a trailing < if there is one in the MRZ string.
            string mrzString            = identification.MrzString;
            string passportNumberForNFC = String.Copy(passportNumber);

            while (passportNumberForNFC.Length < 9)
            {
                passportNumberForNFC += "<";
            }

            stopMRZScanning();
            this.passportNumberForNFC = passportNumberForNFC;
            this.dateOfBirth          = dateOfBirth;
            this.dateOfExpiry         = dateOfExpiry;
            readNFCChip();
        }
Esempio n. 2
0
 public void DidFindResult(ALIDScanPlugin anylineIDScanPlugin, ALIDResult scanResult)
 {
     HandleResult(scanResult);
 }
Esempio n. 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            float hintMargin = 2;

            // Set the background color to black to have a nicer transition
            View.BackgroundColor = UIColor.Black;

            UILabel hintViewLabel = new UILabel(CGRect.Empty);

            hintView = new UIView(CGRect.Empty);

            hintViewLabel.Text = @"Scan MRZ";
            hintViewLabel.SizeToFit();

            hintView.AddSubview(hintViewLabel);

            hintView.Frame = new UIEdgeInsets(hintViewLabel.Frame.Top, hintViewLabel.Frame.Left, hintViewLabel.Frame.Bottom, hintViewLabel.Frame.Right)
                             .InsetRect(new CGRect(-hintMargin, -hintMargin, -hintMargin, -hintMargin));
            hintView.Center = new CGPoint(View.Center.X, 0);
            hintViewLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            hintViewLabel.CenterYAnchor.ConstraintEqualToSystemSpacingBelowAnchor(hintView.CenterYAnchor, 0);
            hintViewLabel.CenterXAnchor.ConstraintEqualToSystemSpacingAfterAnchor(hintView.CenterXAnchor, 0);
            hintView.Layer.CornerRadius  = 8;
            hintView.Layer.MasksToBounds = true;
            hintView.BackgroundColor     = UIColor.Black.ColorWithAlpha(0.5f);
            hintViewLabel.TextColor      = UIColor.White;
            View.AddSubview(hintView);

            ALMRZConfig mrzConfig = new ALMRZConfig();
            //we want to be quite confident of these fields to ensure we can read the NFC with them
            ALMRZFieldConfidences fieldConfidences = new ALMRZFieldConfidences();

            fieldConfidences.DocumentNumber = 90;
            fieldConfidences.DateOfBirth    = 90;
            fieldConfidences.DateOfExpiry   = 90;
            mrzConfig.IdFieldConfidences    = fieldConfidences;

            //Create fieldScanOptions to configure individual scannable fields
            ALMRZFieldScanOptions scanOptions = new ALMRZFieldScanOptions();

            scanOptions.VizAddress      = ALFieldScanOption.Default;
            scanOptions.VizDateOfIssue  = ALFieldScanOption.Default;
            scanOptions.VizSurname      = ALFieldScanOption.Default;
            scanOptions.VizGivenNames   = ALFieldScanOption.Default;
            scanOptions.VizDateOfBirth  = ALFieldScanOption.Default;
            scanOptions.VizDateOfExpiry = ALFieldScanOption.Default;

            //Set scanOptions for MRZConfig
            mrzConfig.IdFieldScanOptions = scanOptions;

            NSError error = null;

            //Init the anyline ID ScanPlugin with an ID, Licensekey, the delegate,
            //  the MRZConfig (which will configure the scan Plugin for MRZ scanning), and an error
            this.mrzScanPlugin = new ALIDScanPlugin(@"ModuleID", AnylineViewController.LicenseKey, this, mrzConfig, out error);

            nfcDetector = new ALNFCDetector(AnylineViewController.LicenseKey, this);

            mrzScanViewPlugin = new ALIDScanViewPlugin(mrzScanPlugin);

            var frame = UIScreen.MainScreen.ApplicationFrame;

            frame = new CGRect(frame.X,
                               frame.Y + NavigationController.NavigationBar.Frame.Size.Height,
                               frame.Width,
                               frame.Height - NavigationController.NavigationBar.Frame.Size.Height);

            // This is the main intialization method that will create our use case depending on the JSON configuration.
            scanView = new ALScanView(frame, mrzScanViewPlugin);
            scanView.ScanViewPlugin.AddScanViewPluginDelegate(new CutoutListener(updateHintPosition, scanView));
            scanView.FlashButtonConfig.FlashAlignment = ALFlashAlignment.TopLeft;

            // After setup is complete we add the scanView to the view of this view controller
            View.AddSubview(scanView);
            View.SendSubviewToBack(scanView);

            var topGuide = TopLayoutGuide;

            var viewNames = NSDictionary.FromObjectsAndKeys(new object[] {
                scanView,
                topGuide,
            }, new NSObject[] {
                new NSString("scanView"),
                new NSString("topGuide"),
            });
            var emptyDict = new NSDictionary();


            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[scanView]|", 0, emptyDict, viewNames));
            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[topGuide]-0-[scanView]|", 0, emptyDict, viewNames));

            scanView.StartCamera();
        }