Skip to main content

Usage

Sample Flows

BioMatch Register Flow

This section outlines the typical flow for registering a user using the BioMatch SDK.

  1. Obtain the token of a verified profile.
  2. Configure the SDK with the retrieved token and server URL.
  3. Call the PIN start func to display the PIN entry screen.
  4. After the PIN callback is triggered, call PIN Enable to register the PIN for the verified profile.

BioMatch Auth/Payment Flow

This section outlines the typical flow for performing authentication or payment using the BioMatch SDK.

  1. Obtain a general token independent of any specific profile.
  2. Display the Selfie View to capture the user’s face.
  3. After the Selfie Process is completed, navigate to the PIN Screen.
  4. Once the PIN callback is triggered, call the Selfie upload function, passing the user-entered PIN as a parameter.
  5. Use the result of the upload callback to determine whether the authentication or payment was successful.

Usage - AmaniBioMatchSDK

Pin Screen Usage


import UIKit
import AmaniBioMatch


class demoVC: UIViewController {
private var pinView: UIView?
private var amaniBioMatch: AmaniBioMatchSDK? = nil

override func viewDidLoad() {
super.viewDidLoad()

let amaniBioMatch = AmaniBioMatchSDK(
baseURL: URL(string: "https://your.env.example")!,
tokenProvider: "<TOKEN>"
)
self.amaniBiomatch = amaniBioMatch

}

@MainActor
func showPinScreen() {
let pinManager = self.amaniBiomatch.PIN()

// Configure look & behavior (all fields optional)
let pinConfig = PinScreenConfig(
pinLength: 4,
title: "Enter PIN",
subtitle: "Please enter your security PIN",
backgroundHex: "FFFFFF",
titleHex: "111111",
subtitleHex: "666666",
pinDotFilledHex: "0EA5E9",
pinDotEmptyHex: "E5E7EB",
keypadButtonBackgroundHex: "F3F4F6",
keypadButtonNumberHex: "111111",
keypadButtonBorderHex: "E5E7EB",
deleteButtonContentHex: "EF4444",
deleteButtonBackgroundHex: "FFF7ED",
deleteButtonBorderHex: "F59E0B"
)

guard let pinView = try? pinManager.start(config: pinConfig, completion: { [weak self] enteredPin in
// Called when user completes entry
self?.enableBiopayPin(pin: enteredPin)
}) else { return }

pinView.frame = view.bounds
view.addSubview(pinView)
}


private func enableBiopayPin(pin: String) {
pinManager.enablePin(pin) { result in
switch result {
case .success(let value):
print("Enable success:", value.status)
case .failure(let error):
print("Enable failed:", error)
}
}
}

private func disableBiopayPin() {
pinManager.disablePin { result in
switch result {
case .success(let value):
print("Disable success:", value.status)
case .failure(let error):
print("Disable failed:", error)
}
}
}



}





SDK Operations

This section covers operations you can perform with the SDK after the user has interacted with the Views.
It includes enabling PIN verification and uploading selfies for authentication or payment flows.

Enable PIN Verification

To enable the PIN, it must belong to a verified profile. Make sure the user’s profile is already verified before calling this.
This method should be called after the PIN View completes and the PIN data is obtained.

Optionally, you can pass a PIN value from your own PIN screen if you have a custom implementation.

Selfie Screen Usage


import UIKit
import AmaniBioMatch


class demoVC: UIViewController {
private var selfieView: UIView?
private var amaniBioMatch: AmaniBioMatchSDK? = nil

override func viewDidLoad() {
super.viewDidLoad()

let amaniBioMatch = AmaniBioMatchSDK(
baseURL: URL(string: "https://your.env.example")!,
tokenProvider: "<TOKEN>"
)
self.amaniBiomatch = amaniBioMatch

}

@MainActor
func showSelfieScreen() {
let selfieManager = self.amaniBiomatch.Selfie()

// Configure look & behavior (all fields optional)
let selfieConfig = SelfieScreenConfig(
manualCaptureButtonInnerHex: "3B82F6",
manualCaptureButtonOuterHex: "3B82F6",
appFontHex: "FFFFFF",
appBackgroundHex: "FFFFFF",
instructionText: "Align your face within the oval",
permissionDeniedTitle: "Permissions Required",
permissionDeniedMessage: "To capture a selfie, please grant Camera access.",
retryButtonText: "Retry",
settingsButtonText: "Open Settings",
permissionHandling: .automatic( // or .manual
alertTexts: SelfiePermissionAlertTexts(
title: "Permissions Required",
message: "Camera access is needed to continue.",
openSettings: "Settings",
cancel: "Cancel"
)
)
)


guard let selfieView = try? selfieManager.start(config: selfieConfig, completion: { [weak self] image in
// User captured a selfie (UIImage)
self.uploadSelfie(pin: "1234")
}) else { return }


selfieView.frame = view.bounds
view.addSubview(selfieView)
}


private func uploadSelfie(pin: String) {
selfieManager.upload(pin: pin, location: nil) { result in
switch result {
case .success(let value):
print("Selfie upload success:", value.status) // BioMatchSelfieResult
case .failure(let error):
print("Selfie upload failed:", error)
}
}
}

}

Upload Selfie with PIN

The upload method uploads the selfie together with the user’s PIN for verification or payment flows.
Only the PIN is passed as a parameter; the selfie data is handled internally by the SDK.
This method must only be called after the Selfie View has successfully completed, because the SDK needs the captured selfie internally to perform the upload. Calling it before the selfie is captured may result in errors or invalid uploads.