Bring the power of CLEAR's web verification service to your iOS application!
To set up a partnership, reach out to [email protected]. A clientIdentifier
must be provided during onboarding before using the SDK.
File
->Add Packages
.Up to Next Major Version
is recommended.Add Package
.Clear
is selected and added to the correct target.Add Package
again.Clear.xcframework.zip
.Copy items if needed
.Build Phases
->Link Binary With Libraries
.Build Phases
->Embed Frameworks
.import Clear
CLEAR
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 to integration
while onboarding. Change to production
after 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, ://auth
is appended automatically.// Initialize using an example scope.
let configuration = CLEAR.Configuration(environment: .integration, clientIdentifier: "my-client-id", scope: "email given_name")
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...
link |
Stars: 3 |
Last commit: 3 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics