Bring the power of CLEAR's web verification service to your iOS application!
- Swift 5+
- iOS 12+
- Xcode 13+
To set up a partnership, reach out to [email protected]. A clientIdentifier must be provided during onboarding before using the SDK.
- Open Xcode.
- Navigate to
File->Add Packages. - Add package https://github.com/clearsecureidentity/clear-ios-sdk.git.
- Select a dependency rule.
Up to Next Major Versionis recommended. - Select
Add Package. - Ensure
Clearis selected and added to the correct target. - Select
Add Packageagain.
- Navigate to releases.
- Select the latest version.
- Download
Clear.xcframework.zip. - Unzip the framework.
- Add the framework to your Xcode project. Be sure to check
Copy items if needed. - Ensure the framework is visible in
Build Phases->Link Binary With Libraries. - Add the framework to
Build Phases->Embed Frameworks.
import ClearCLEAR is the root class of the SDK. An application must initialize this using a CLEAR.Configuration struct before using any functionality. This will usually happen in AppDelegate or SceneDelegate. The struct contains the following required values:
environment: Set tointegrationwhile onboarding. Change toproductionafter proper functionality is verified.clientIdentifier: A client specific value given during onboarding.scope: A space-delimited string of all desired user properties
Optional Values:
callbackScheme: Defaults to the bundle identifier of the client application. In most cases this will not change. When supplying a custom value,://authis appended automatically.loginHint: An optional user identifier (phone number or email) to pre-populate the web verification login screenforgetMember: An optional boolean (not available in production) that indicates whether or not the member will be purged after data sharing is complete. (useful for testing new enrollment flow)
// Initialize using an example scope.
let configuration = CLEAR.Configuration(environment: .integration, clientIdentifier: "my-client-id", scope: "email given_name", loginHint: "+15554844263", forgetMember: true)
CLEAR.initialize(with: configuration)VerificationView is a UI component that triggers the web verification process when tapped.
// Initialize VerificationView from inside a view controller.
let verificationView = VerificationView(delegate: self)
view.addSubview(verificationView)VerificationDelegate provides additional configuration details, and sends back the result of verification.
extension ViewController: VerificationDelegate {
/// The view controller that will launch the verification process.
var hostViewController: UIViewController { self }
/// Called when the verification process is complete.
func verificationDidComplete(withResult result: Result<CLEAR.Response, CLEAR.Error>) {
switch result {
// Handle a successful result accordingly.
case .success(let result): print(result.authorizationCode)
// Handle a unsuccessful result accordingly.
case .failure(let error): print(error.errorDescription)
}
}
}After a successful verification, a CLEAR.Response struct is returned in the verificationDidComplete(withResult:) delegate method. This struct contains an authorizationCode, which can be used to request additional information about a CLEAR member.
After an unsuccessful verification, a CLEAR.Error enum is returned in the verificationDidComplete(withResult:) delegate method. This enum contains one of the possible error cases:
-
cancelled: The operation was cancelled.
-
invalidVerificationPath: The configuration is invalid.
-
missingHostViewController: A hostViewController must be supplied.
-
stateGenerationFailed: Failed to generate a state value.
-
sessionFailed: Something has gone wrong with the session.
-
missingRedirectResponse: No redirect URL was found in the response.
-
missingAuthorizationCode: The authorization code was not found.
-
stateIntegrityFailed: There was an internal state integrity error.
-
unknown: An unexpected error occurred.
Coming soon...