✨Works out of the box guarantee. If you face any issue at all, hit us up on Telegram and we will write the integration for you.
logoReclaim Protocol Docs
iOS SDK

Usage

Reclaim Protocol's InApp iOS SDK for ZK proof generations for requests with an in-app experience of web verification

Use ReclaimInAppSdk in your project

To use ReclaimInAppSdk in your project, follow these steps:

  1. Import the ReclaimInAppSdk module into your Swift file.
import ReclaimInAppSdk
  1. Create a request object.
let request = ReclaimVerification.Request.params(
    try .init(
        /// You can use the appId and secret from Reclaim Devtools to create a request.
        /// Providing appId and secret here in this initializer is optional.
        /// If you don't provide it, the SDK will use the appId and secret from the Info.plist file.
        // appId: "YOUR_APP_ID_FROM_RECLAIM_DEVTOOLS",
        // secret: "YOUR_APP_SECRET_FROM_RECLAIM_DEVTOOLS",
        /// This is the provider id that you've added to your app in Reclaim Devtools.
        /// The verification flow will use the provider information fetch by this provider id.
        providerId: providerId
    )
)

More ways to create a request object are available in the ReclaimVerification.Request.* apis.

  1. Start the verification flow.
// This is the function that starts the verification flow.
// This may fail if device screen is getting shared.
let result = try await ReclaimVerification.startVerification(request)

The returned result is a ReclaimVerification.Response object. This object contains a response that has proofs, exception, and the sessionId if the verification is successful.

If the verification is cancelled or failed, the result will contain an exception.

You can use the ReclaimVerification.Response object to get the proof, exception, and sessionId.

let proof = result.response.proofs
let exception = result.response.exception
let sessionId = result.response.sessionId

If the verification is successful, the proof will contain the data that you need to store in your database.

If the verification is cancelled or failed, the exception will contain the error details.

In the above apis, ReclaimVerification.Request.*, ReclaimVerification.startVerification or ReclaimVerification.startVerificationFromUrl can also throw an error. The error can be one of the following:

  • ReclaimVerificationError.cancelled: The verification was cancelled by the user.
  • ReclaimVerificationError.dismissed: The verification was dismissed by the sdk.
  • ReclaimVerificationError.failed(let error): The verification failed due to an error.
  • ReclaimVerificationError.sessionExpired: The verification session expired.

You can handle the error by using a do-catch block. For example:

do {
    let result = try await ReclaimVerification.startVerification(request)
} catch ReclaimVerificationError.cancelled {
    print("Verification cancelled")
} catch ReclaimVerificationError.dismissed {
    print("Verification dismissed")
}

For a complete example, see the Reclaim Example - SwiftUI.

Advanced Usage

For more usage options see Advance Options guide

Example

Upgrading

To upgrade to a new version of the Reclaim InApp SDK, follow these steps:

  1. Make sure you have the latest version of the Reclaim InApp SDK. Currently the latest version is v0.3.0.
  2. Incase of any problems: remove package, clear build, restart Xcode, and add package again.

Migration guides will be available when a new version with API changes is released.

On this page