In the storyboard for the ViewControlle
r class that will capture the id card, add a CaptureIDCardVideoPreview
. CaptureIDCardVideoPreview
is a class that is defined in the Smile Identity SDK. It will be used to capture the id card.
To add the CaptureIDCardVideoPreview
in the storyboard do the following steps: .
Add a UIView
to a ViewController
Scene.
Select the UIView
, and select CaptureIDCardVideoPreview
as the Class. Set the Module to Smile_Identity_SDK, and uncheck the Inherit Module From Target, as the image below shows.
​​
​
Add the CaptureIDCardVideoPreview
as an outlet and name it previewView
Make the ViewController
be a delegate for the capture selfie callbacks
class MyIDCardViewController: UIViewController, CaptureSelfieDelegate
Declare a CaptureIDCard
variable at the class level
var captureIDCard : CaptureIDCard?
Override the viewWillAppear
function and add the following lines. The previewView
is the control that was added the the storyboard. userTag
is the custom user tag. In this example, it is send the default user tag value that is defined in the SmileIDSingleton.
captureIDCard = CaptureIDCard()captureIDCard?.setup(captureIDCardDelegate: self,previewView: previewViewuserTag:SmileIDSingleton.DEFAULT_USER_TAG )self.view.bringSubview(toFront: previewView)AppDelegate.AppUtility.lockOrientation(UIInterfaceOrientationMask.landscapeRight,andRotateTo:UIInterfaceOrientation.landscapeRight)
Override the viewDidAppear
function and add the following line.
captureIDCard?.start()
Override the viewWillAppear
function and add the following line.
AppDelegate.AppUtility.lockOrientation(UIInterfaceOrientationMask.portrait, andRotateTo:UIInterfaceOrientation.portrait)
Override the viewWillDisappear
function and add the following line.
captureIDCard?.stop()
Implement the CaptureIDCardDelegate
callbacks