From e4a48d0e15d09903f374d554ea215e647769f31c Mon Sep 17 00:00:00 2001 From: Mushaheed Syed Date: Sun, 16 Nov 2025 05:17:40 +0530 Subject: [PATCH] Update docs for inapp SDKs --- .../installation.mdx | 1 + .../{android-kotlin => android}/meta.json | 0 .../{android-kotlin => android}/usage.mdx | 44 +-- content/docs/flutter/installation.mdx | 53 ++-- content/docs/flutter/usage.mdx | 13 +- .../inapp-sdks/advanced/attestor-auth.mdx | 195 ++++++++++++++ content/docs/inapp-sdks/advanced/intro.mdx | 14 + content/docs/inapp-sdks/advanced/meta.json | 9 + .../advanced/overrides.mdx} | 175 ++---------- .../advanced/verification-options.mdx | 19 ++ content/docs/inapp-sdks/introduction.mdx | 42 +++ content/docs/inapp-sdks/meta.json | 7 + content/docs/ios-swift/installation.mdx | 177 ++++++++++-- content/docs/ios-swift/usage.mdx | 55 +--- content/docs/js-sdk/verifying-proofs.mdx | 2 +- content/docs/meta.json | 3 +- content/docs/react-native/install/expo.mdx | 96 +++++++ content/docs/react-native/install/meta.json | 7 + .../react-native/install/no-framework.mdx | 212 +++++++++++++++ content/docs/react-native/installation.mdx | 253 ++++++++---------- content/docs/react-native/meta.json | 4 +- content/docs/react-native/troubleshooting.mdx | 103 +++++++ 22 files changed, 1057 insertions(+), 427 deletions(-) rename content/docs/{android-kotlin => android}/installation.mdx (96%) rename content/docs/{android-kotlin => android}/meta.json (100%) rename content/docs/{android-kotlin => android}/usage.mdx (56%) create mode 100644 content/docs/inapp-sdks/advanced/attestor-auth.mdx create mode 100644 content/docs/inapp-sdks/advanced/intro.mdx create mode 100644 content/docs/inapp-sdks/advanced/meta.json rename content/docs/{react-native/usage.mdx => inapp-sdks/advanced/overrides.mdx} (62%) create mode 100644 content/docs/inapp-sdks/advanced/verification-options.mdx create mode 100644 content/docs/inapp-sdks/introduction.mdx create mode 100644 content/docs/inapp-sdks/meta.json create mode 100644 content/docs/react-native/install/expo.mdx create mode 100644 content/docs/react-native/install/meta.json create mode 100644 content/docs/react-native/install/no-framework.mdx create mode 100644 content/docs/react-native/troubleshooting.mdx diff --git a/content/docs/android-kotlin/installation.mdx b/content/docs/android/installation.mdx similarity index 96% rename from content/docs/android-kotlin/installation.mdx rename to content/docs/android/installation.mdx index 136c306..528415a 100644 --- a/content/docs/android-kotlin/installation.mdx +++ b/content/docs/android/installation.mdx @@ -73,3 +73,4 @@ Optional permissions (requested by specific providers at runtime): ``` +To use Reclaim InAppSdk in your project, follow the [Usage guide](/android/usage). diff --git a/content/docs/android-kotlin/meta.json b/content/docs/android/meta.json similarity index 100% rename from content/docs/android-kotlin/meta.json rename to content/docs/android/meta.json diff --git a/content/docs/android-kotlin/usage.mdx b/content/docs/android/usage.mdx similarity index 56% rename from content/docs/android-kotlin/usage.mdx rename to content/docs/android/usage.mdx index 70084eb..d78e337 100644 --- a/content/docs/android-kotlin/usage.mdx +++ b/content/docs/android/usage.mdx @@ -45,46 +45,10 @@ ReclaimVerification.startVerification( ) ``` -## Example - -[Complete Android example](https://github.com/reclaimprotocol/reclaim-inapp-android-sdk/tree/main/example) with Jetpack Compose - -# Advanced Options -## Complete Request Parameters - -```kotlin -val request = ReclaimVerification.Request( - // Required - appId = "YOUR_APP_ID", - secret = "YOUR_APP_SECRET", - providerId = "YOUR_PROVIDER_ID", +The returned result `ReclaimVerification.ResultHandler.onResponse` in is a `ReclaimVerification.Response` object. This object contains a response that has proofs, exception, and the sessionId if the verification is successful. - // Optional - session = ReclaimVerification.ReclaimSessionInformation( - sessionId = "session-id", - timestamp = "1234567890", - signature = "signature" - ), +If the verification is cancelled or failed, the handler's `ReclaimVerification.ResultHandler.onException` method is called with a `ReclaimVerification.ReclaimVerificationException` object. - contextString = "additional-context", // Additional context data - - parameters = mapOf( // Custom provider parameters - "customParam" to "value" - ), - - providerVersion = ReclaimVerification.Request // Specify provider version - .ProviderVersion.resolved("1.0.0") -) -``` - -## Troubleshooting - -### Cronet Errors (Devices without Google Play Services) - -If you see Cronet-related errors on devices without Play Services, add embedded Cronet: +## Example -```gradle -dependencies { - implementation("org.chromium.net:cronet-embedded:141.7340.3") -} -``` \ No newline at end of file +[Complete Android example](https://github.com/reclaimprotocol/reclaim-inapp-android-sdk/tree/main/example) with Jetpack Compose diff --git a/content/docs/flutter/installation.mdx b/content/docs/flutter/installation.mdx index 61baee4..ed95ab8 100644 --- a/content/docs/flutter/installation.mdx +++ b/content/docs/flutter/installation.mdx @@ -3,6 +3,8 @@ title: Installation description: Flutter SDK for Reclaim Protocol --- +import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; + ## Prerequisites - An Android device or emulator running Android 5.0 or later. @@ -14,7 +16,7 @@ Setup your project using the [Get API Key guide](/api-key). ### Using Flutter CLI ```bash -flutter pub add reclaim_inapp_sdk +flutter pub add https://github.com/reclaimprotocol/reclaim-inapp-flutter-sdk.git ``` ### Manual Installation @@ -22,7 +24,10 @@ flutter pub add reclaim_inapp_sdk Add the following to your `pubspec.yaml`: ```yaml dependencies: - reclaim_inapp_sdk: ^latest_version + reclaim_inapp_flutter_sdk: + git: + url: https://github.com/reclaimprotocol/reclaim-inapp-flutter-sdk.git + ref: 0.15.0 ``` Then run: @@ -41,28 +46,44 @@ Update your `android/app/build.gradle`: ```gradle android { defaultConfig { - minSdkVersion 21 // Minimum Android 5.0 - targetSdkVersion 34 + minSdkVersion 24 + targetSdkVersion 36 } } ``` -#### Cronet for Devices Without Play Services - -If you need to support Android devices without Google Play Services, add the embedded Cronet library: - -```gradle -dependencies { - // Use embedded cronet for devices without play services - implementation("org.chromium.net:cronet-embedded:119.6045.31") -} -``` - ### iOS Configuration Update your `ios/Podfile`: ```ruby -platform :ios, '13.0' # Minimum iOS 13.0 +platform :ios, '14.0' ``` +#### Update Environment Variables for XCScheme + + + + +1. Open your project in Xcode. +2. Click on the project target. +3. Click on the **Scheme** dropdown. + +Edit current xcscheme in Xcode + +4. Click on the **Edit Scheme** button. +5. Click on the **Run** tab. +6. Click on the **Arguments** tab and check the **Environment Variables** section. + +Enable Debug executable in Xcode + +7. Add the following environment variable: + - Key: `GODEBUG` + - Value: `asyncpreemptoff=1` +8. Click on the **Close** button in the dialog and build the project. +9. Run the app on a physical device. + + + + +To use Reclaim InAppSdk in your project, follow the [Usage guide](/flutter/usage). \ No newline at end of file diff --git a/content/docs/flutter/usage.mdx b/content/docs/flutter/usage.mdx index 4244590..f48953a 100644 --- a/content/docs/flutter/usage.mdx +++ b/content/docs/flutter/usage.mdx @@ -19,7 +19,6 @@ const String providerId = String.fromEnvironment('PROVIDER_ID'); - You can get the `APP_ID` and `APP_SECRET` using [this guide](/api-key) - The `PROVIDER_ID` is the proof you want the user to generate. You can see all the [available providers here](https://dev.reclaimprotocol.org/explore). - ## Starting Verification Create a `ReclaimVerification` instance from your BuildContext: @@ -46,6 +45,18 @@ final proofs = result.proofs; print('Received ${proofs.length} proofs'); ``` +### Pre-warming + +For better performance, you can pre-warm the SDK before use: + +```dart +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + ReclaimInAppSdk.preWarm(); + runApp(MyApp()); +} +``` + ## Verifying proofs The `startVerification()` method returns a `ReclaimVerificationResult` containing: diff --git a/content/docs/inapp-sdks/advanced/attestor-auth.mdx b/content/docs/inapp-sdks/advanced/attestor-auth.mdx new file mode 100644 index 0000000..1bc2df2 --- /dev/null +++ b/content/docs/inapp-sdks/advanced/attestor-auth.mdx @@ -0,0 +1,195 @@ +--- +title: Attestor Authentication +description: Reclaim Protocol's InApp SDKs setup when using an attestor with authentication +--- + +import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; + +# Get Started + +A private attestor can have authentication enabled which blocks all un-authenticated connections and can also be used to limit the hosts that can be connected to. InApp SDKs can be configured to use another attestor and include an auth request in the claim sent to this attestor. + +Read more about [attestors authentication here](https://github.com/reclaimprotocol/attestor-core/blob/main/docs/run-server.md#enabling-authentication). + +## Basic Usage + +An auth request can be created anywhere, even on your server. JS library @reclaimprotocol/attestor-core from npm can be used for creating an auth request. + +```typescript +import { createAuthRequest, B64_JSON_REPLACER } from '@reclaimprotocol/attestor-core' + +// this can happen on another server, on the client or anywhere you'd +// like +const authRequest = await createAuthRequest( + { + // optional user ID -- to identify the user + // all logs on the backend will be tagged with this + id: 'optional-user-id', + // only allow the user to tunnel requests to one of + // these hosts + hostWhitelist: ['github.com', 'example.com'] + }, + keyPairs.privateKey +) +const yourAttestorAuthRequest = JSON.stringify( + authRequest, + B64_JSON_REPLACER, + 2 +) +console.info({ yourAttestorAuthRequest }); +``` + +An auth request looks like this: + +```json +{ + "data": { + "userId": "optional-user-id", + "hostWhitelist": ["api.abcd.xyz"] + }, + "signature": { + "type": "uint8array", + "value": "base64-encoded-signature" + } +} +``` + +This can be used in the `setVerificationOptions` method of the InApp SDK, which allows you to set a callback for providing an auth request to the attestor. + + + +```typescript tabs="Typescript" +const reclaimVerification = new ReclaimVerification(); + +// This is how you may be using a different attestor with overrides +await reclaimVerification.setOverrides({ + featureOptions: { + // overridden attestor browser rpc url + attestorBrowserRpcUrl: 'https://myattestor.example.org/browser-rpc', + // other overrides (removed for brevity) + }, +}); + +// Provide a callback to provide attestor auth request. +await reclaimVerification.setVerificationOptions({ + fetchAttestorAuthenticationRequest: async (providerInformationJsonString: string) => { + // sample attestor auth request + return JSON.stringify({ + "data": { + "createdAt": 1741648166, + "expiresAt": 1741649066, + "id": "optional-user-id", + "hostWhitelist": [ + "github.com", + "example.com" + ] + }, + "signature": { + "type": "uint8array", + "value": "gSCbBMZSdNJjrxGUTPoERj5S8jtkwQEnGWmmMXx+j3wrd7pspRkfhE96DauFQTVcp+ErB7zWaBDAWwThOu4Fkxw=" + } + }); + }, +}); +``` + +```kotlin tabs="Kotlin" +ReclaimVerification.setOverrides( + context = context, + featureOptions = ReclaimOverrides.FeatureOptions( + // overridden attestor browser rpc url + attestorBrowserRpcUrl = "https://myattestor.example.org/browser-rpc" + // other overrides (removed for brevity) + ) +) { result -> + result + .onSuccess { + Log.d("MainActivity", "Reclaim Overrides set") + } + .onFailure { e -> + Log.e("MainActivity", "Could not set overrides", e) + } +} + +ReclaimVerification.setVerificationOptions( + context = context, + options = ReclaimVerification.VerificationOptions( + attestorAuthRequestProvider = object : ReclaimVerification.VerificationOptions.AttestorAuthRequestProvider { + override fun fetchAttestorAuthenticationRequest( + reclaimHttpProvider: Map, + callback: (Result) -> Unit + ) { + // sample attestor auth request + callback(Result.success(""" + { + "data": { + "createdAt": 1741648166, + "expiresAt": 1741649066, + "id": "optional-user-id", + "hostWhitelist": [ + "github.com", + "example.com" + ] + }, + "signature": { + "type": "uint8array", + "value": "gSCbBMZSdNJjrxGUTPoERj5S8jtkwQEnGWmmMXx+j3wrd7pspRkfhE96DauFQTVcp+ErB7zWaBDAWwThOu4Fkxw=" + } + } + """.trimIndent())) + } + } + ) +) { result -> + result + .onSuccess { + Log.d("MainActivity", "Reclaim Verification options set") + } + .onFailure { e -> + Log.e("MainActivity", "Could not set verification options", e) + } +} +``` + +```swift tabs="Swift" +// This is how you may be using a different attestor with overrides +try await ReclaimVerification.setOverrides( + featureOptions: .init( + // overridden attestor browser rpc url + attestorBrowserRpcUrl: "https://myattestor.example.org/browser-rpc" + // other overrides (removed for brevity) + ) +) + +class AttestorAuthRequestProviderImpl : ReclaimVerification.VerificationOptions.AttestorAuthRequestProvider { + func fetchAttestorAuthenticationRequest( + reclaimHttpProvider: [AnyHashable?: (any Sendable)?], + completion: @escaping (Result) -> Void + ) { + // sample attestor auth request + completion(.success(""" + { + "data": { + "createdAt": 1741648166, + "expiresAt": 1741649066, + "id": "optional-user-id", + "hostWhitelist": [ + "github.com", + "example.com" + ] + }, + "signature": { + "type": "uint8array", + "value": "gSCbBMZSdNJjrxGUTPoERj5S8jtkwQEnGWmmMXx+j3wrd7pspRkfhE96DauFQTVcp+ErB7zWaBDAWwThOu4Fkxw=" + } + } + """)) + } +} + +try await ReclaimVerification.setVerificationOptions(options: .init( + attestorAuthRequestProvider: AttestorAuthRequestProviderImpl() +)) +``` + + diff --git a/content/docs/inapp-sdks/advanced/intro.mdx b/content/docs/inapp-sdks/advanced/intro.mdx new file mode 100644 index 0000000..9e94be2 --- /dev/null +++ b/content/docs/inapp-sdks/advanced/intro.mdx @@ -0,0 +1,14 @@ +--- +title: Usage +description: Documentation for advanced usage of Reclaim InApp SDKs. +--- + +# More about Reclaim InApp SDKs + +The InApp SDKs also allows more functionalities, like overriding several configurations used in the verification process by the SDK. + +## Table of Contents + +* [Verification Options](./verification-options) +* [Attestor Auth](./attestor-auth) +* [Overrides](./overrides) diff --git a/content/docs/inapp-sdks/advanced/meta.json b/content/docs/inapp-sdks/advanced/meta.json new file mode 100644 index 0000000..843415d --- /dev/null +++ b/content/docs/inapp-sdks/advanced/meta.json @@ -0,0 +1,9 @@ +{ + "title": "Usage", + "pages": [ + "intro", + "verification-options", + "attestor-auth", + "overrides" + ] +} \ No newline at end of file diff --git a/content/docs/react-native/usage.mdx b/content/docs/inapp-sdks/advanced/overrides.mdx similarity index 62% rename from content/docs/react-native/usage.mdx rename to content/docs/inapp-sdks/advanced/overrides.mdx index 083ccef..ceee380 100644 --- a/content/docs/react-native/usage.mdx +++ b/content/docs/inapp-sdks/advanced/overrides.mdx @@ -1,164 +1,20 @@ --- -title: Usage -description: This SDK allows Reclaim Protocol to be triggered from your app, without changing apps. +title: Overrides +description: Instructions on how to override the default configuration of Reclaim Protocol's InApp SDKs --- -# Quickstart - -## Import `inapp-rn-sdk` - -```js -import { ReclaimVerification } from '@reclaimprotocol/inapp-rn-sdk'; -``` - -## Start Verification - -```js -const reclaimVerification = new ReclaimVerification(); - -const verificationResult = await reclaimVerification.startVerification({ - appId: config.REACT_APP_RECLAIM_APP_ID ?? '', - secret: config.REACT_APP_RECLAIM_APP_SECRET ?? '', - providerId: providerId, -}); -``` -- You can get the `APP_ID` and `APP_SECRET` using [this guide](/api-key) -- The `PROVIDER_ID` is the proof you want the user to generate. You can see all the [available providers here](https://dev.reclaimprotocol.org/explore). - - - -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. - -## Verifying proofs -You don't need to separately verify the proofs as you would [in the js-sdk](/js-sdk/verifying-proofs). If the verification failed, you will get an exception of type `ReclaimVerification.ExceptionType.Failed`. If there is no exception, the proof was generated correctly _and_ verified correctly. - -### Exception Handling -Exceptions -- `ReclaimVerification.ExceptionType.Cancelled` : User cancelled the proof generation process midway -- `ReclaimVerification.ExceptionType.Dismissed` : User closed the proof generation before starting -- `ReclaimVerification.ExceptionType.SessionExpired` : The session took too long to generate a proof. Either the proof generation got stuck indefinitely or it was waiting for the user to take an action (e.g. login). -- `ReclaimVerification.ExceptionType.Failed` : Proof couldn't be generated or verified. - -## Examples - -See complete working examples: -- [React Native Example](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/tree/main/samples/example_new_arch) - for standard React Native projects -- [Expo Example](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/tree/main/samples/example_expo) - for Expo projects - - import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; -# Advanced options - -## Request Parameters - -#### Complete Request Parameters -Below are all the parameters you can set for your proof request creation : -```typescript -const verificationResult = await reclaimVerification.startVerification({ - // Required fields - appId: string, // Your Reclaim app ID - secret: string, // Your Reclaim app secret - providerId: string, // Provider ID from Reclaim Devtools - - // Optional fields - session?: { // Reuse existing session (SDK generates if not provided) - sessionId: string, - timestamp: string, // Milliseconds since Unix epoch - signature: string - }, - - contextString?: string, // Additional context data for verification - - parameters?: { // Custom parameters required by specific providers - [key: string]: string // Check provider details for required parameters - }, - - providerVersion?: { // Specify provider version - resolvedVersion: string, - versionExpression: string - } -}); -``` - -**Example with Optional Parameters:** - -```js -const verificationResult = await reclaimVerification.startVerification({ - appId: 'your-app-id', - secret: 'your-app-secret', - providerId: 'provider-id', - - // Add context for tracking - contextString: 'user-signup-flow', +# Get Started - // Custom parameters (if required by the provider) - parameters: { - customField: 'value' - }, - - // Specify exact provider version - providerVersion: ReclaimVerification.ProviderVersion.resolved('1.0.0') -}); -``` -## Alternative Verification Methods - -### Start from URL - -Start verification directly from a request URL: - -```js -const verificationResult = await reclaimVerification.startVerificationFromUrl( - 'https://api.example.com/verification-request' -); -``` - -### Start from JSON Template - -Start verification using a JSON template: - -```js -const template = { - appId: 'your-app-id', - secret: 'your-app-secret', - providerId: 'provider-id', - // ... other configuration -}; - -const verificationResult = await reclaimVerification.startVerificationFromJson(template); - -## Troubleshooting - -### Cronet Errors on Android - -On Android devices without Google Play Services, you may see Cronet-related errors. Add this dependency to your `android/build.gradle`: - -```gradle -dependencies { - // ... other dependencies - implementation("org.chromium.net:cronet-embedded:119.6045.31") -} -``` - -### expo-dev-client Incompatibility (iOS) - -There's a known incompatibility between `ReclaimInAppSdk` and `expo-dev-client` on iOS that causes network request timeouts. Temporarily remove `expo-dev-client` when testing Reclaim functionality on iOS. - -### iOS Build Issues - -If you encounter CocoaPods compatibility errors: - -```bash -cd ios/ -pod update ReclaimInAppSdk -``` - -## Overrides Many configurations in the InApp SDKs can be overridden. For example, a different attestor can be used, or we can update app info that appears in the verification flow. Reclaim Protocol InApp SDK has some overrides which are restricted and require a **capability access token**. This can be made available upon request. Contact our team to discuss implementation details. + + Schedule a meeting with our engineering team: Schedule Meeting. + The `setOverrides` method allows you to customize various aspects of the Reclaim InApp SDK's behavior. This documentation covers all available override options and their usage. @@ -172,6 +28,10 @@ reclaimVerification.setOverrides({ }); ``` +For example of how to use overrides, see: +- [The React Native example's App.overrides.tsx](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/samples/example_new_arch/src/App.overrides.tsx). +- [The Capacitor example's overrides.ts](https://github.com/reclaimprotocol/reclaim-inapp-capacitor-sdk/tree/main/example-app/src.overrides) + ## Available Override Options ### Provider Configuration @@ -438,3 +298,18 @@ reclaimVerification.setOverrides({ } }); ``` + +## Best Practices + +1. Set overrides before calling `startVerification` +2. Consider setting overrides only once. +3. Handle all session management events appropriately. +4. Use appropriate timeout values for your use case +5. Test thoroughly when modifying default behaviors + +## Notes + +- All override options are optional +- Overrides persist until explicitly changed or cleared with `clearAllOverrides` +- Some features may require specific override combinations to work properly +- Overriding all options will cause the app to not use *any* reclaim protocol APIs. diff --git a/content/docs/inapp-sdks/advanced/verification-options.mdx b/content/docs/inapp-sdks/advanced/verification-options.mdx new file mode 100644 index 0000000..d2320b7 --- /dev/null +++ b/content/docs/inapp-sdks/advanced/verification-options.mdx @@ -0,0 +1,19 @@ +--- +title: Verification Options +description: Customize the default verification flow with Reclaim Protocol's InApp SDKs +--- + +import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; +import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; + +## Options API + +The InApp SDKs provide an `setVerificationOptions` method to customize the verification flow. Below are the available options that can be set: + +| Prop | Type | Description | +| ---------------------------------------------- | -------------------------------------- | ----------------------------------------------------------------------------- | +| **`canDeleteCookiesBeforeVerificationStarts`** | boolean | This is enabled by default. Set false to persist sessions storage for the user. (This will be replaced with `canClearWebStorage` in an upcoming update) | +| **`canUseAttestorAuthenticationRequest`** | boolean | Enable the use of authentication request when starting a verification | +| **`claimCreationType`** | 'standalone' \| 'meChain' | The type of claim creation to use. Defaults to 'standalone'. | +| **`canAutoSubmit`** | boolean | Whether to automatically submit the proof after generation. Defaults to true. When false, a prompt to submit is shown to the user. | +| **`isCloseButtonVisible`** | boolean | Whether the close button is visible in the verification screen. Defaults to true. | diff --git a/content/docs/inapp-sdks/introduction.mdx b/content/docs/inapp-sdks/introduction.mdx new file mode 100644 index 0000000..0527274 --- /dev/null +++ b/content/docs/inapp-sdks/introduction.mdx @@ -0,0 +1,42 @@ +--- +title: Introduction +description: The InApp SDKs enables seamless in-app verification experience for your users. No redirection, and no requirement for installing a new app—really no need for your users to leave your app! +--- + +## Integration + +Following is an example on how we used the [Github Username Provider](https://dev.reclaimprotocol.org/provider/6d3f6753-7ee6-49ee-a545-62f1b1822ae5) with the InApp SDK in an ios native application to verify Github account ownership. + + + +This is how Reclaim's verification flow can be fully integrated within your native mobile application. + +## Get Started + +The InApp SDKs are available on all major mobile platforms. For each platform, you can find the installation & usage instructions in the following pages: + +* [Android](/android/installation) +* [iOS](/ios-swift/installation) +* [React Native](/react-native/installation) +* [Flutter](/flutter/installation) +{/* * [Ionic - Capacitor](./installation/ionic-capacitor) */} + +You can request an addition of new platform/framework, contact us for more info. + +## Advanced Usage + +You can customize the verification flow with options, and, as an advanced use—set up overrides or use authentication with the attestor. Learn more from [the Usage documentation](./advanced/intro). + +### Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. + +### Issues and Feedback + +Please feel free to file feature requests and bugs at the issue tracker of InApp sdks. Don't hesitate to contact us if you need any help ;) + +### Stay Updated + +- Join our [Telegram community](https://t.me/protocolreclaim) +- Follow [@reclaimprotocol](https://twitter.com/reclaimprotocol) on Twitter +- Watch our [GitHub repository](https://github.com/reclaimprotocol) diff --git a/content/docs/inapp-sdks/meta.json b/content/docs/inapp-sdks/meta.json new file mode 100644 index 0000000..fc30900 --- /dev/null +++ b/content/docs/inapp-sdks/meta.json @@ -0,0 +1,7 @@ +{ + "title": "Reclaim InApp SDKs", + "pages": [ + "introduction", + "advanced" + ] +} \ No newline at end of file diff --git a/content/docs/ios-swift/installation.mdx b/content/docs/ios-swift/installation.mdx index 4ef1149..544e6c9 100644 --- a/content/docs/ios-swift/installation.mdx +++ b/content/docs/ios-swift/installation.mdx @@ -15,51 +15,172 @@ Setup your project using the [Get API Key guide](/api-key). ## Installation -### Swift Package Manager (Recommended) -1. In Xcode: **File** → **Add Package Dependency** -2. Enter URL: `https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git` -3. Click **Add Package** and select your app target +### 1. Adding Reclaim InApp SDK to your Xcode Project -### CocoaPods + + -Add to your `Podfile`: +Copy the following URL and use it to add Swift Package Manager (SPM) dependency into the Xcode project: + +``` +https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git +``` + +#### How to add a Swift Package Manager (SPM) dependency to your Xcode project: + +1. In your Xcode Editor's toolbar, click on `File` > `Add Package Dependency...`. +Add a dependency to your Xcode project +2. In the `Add Package Dependency` dialog box, paste the URL `https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git` into the `Search or Enter package URL` field on the top right corner of dialog box. +Add a dependency to your Xcode project +3. Click `Add Package`. +4. In the other window, select your **app target** in the `Add to Targets` section and then click `Add package`. +Add a dependency to your Xcode project + +This should complete the installation of the Reclaim InApp SDK. Now follow the [steps below to link the necessary frameworks to your Xcode project](#2-add-reclaims-xcframeworks-to-your-xcode-project). + +##### Note + +- It's worth noting that you should commit the **swiftpm** folder that will be built and more specifically that the **Package.resolved** file should be included in your source control/git. + + + + + +1. Make sure to define a global platform for your project in your `Podfile` with version 13.0 or higher. - - ```ruby -platform :ios, '14.0' +platform :ios, '13.0' +``` + +2. Add the following to your `Podfile` to override the default version of the ReclaimInAppSdk (optional): + + + -pod 'ReclaimInAppSdk', '~> 0.21.1' +```ruby tabs="From Cocoapods (recommended)" +pod 'ReclaimInAppSdk' '~> 0.3.0' ``` - - -```ruby -platform :ios, '14.0' +```ruby tabs="From a specific tag" +pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :tag => '0.3.0' +``` + +```ruby tabs="From git HEAD" +pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git' +``` + +```ruby tabs="From a specific commit" +pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :commit => '027e18b8b2365fd935e9e8585e31fa886c3af6ee' +``` -pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :tag => '0.21.1' +```ruby tabs="From a specific branch" +pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :branch => 'main' ``` - - + + +2. After adding the dependency, your podfile may look like this: + ```ruby -platform :ios, '14.0' +platform :ios, '13.0' -pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git' +target 'GitPodSwiftUIExample' do + # Comment the next line if you don't want to use dynamic frameworks + use_frameworks! + + # Pods for GitPodSwiftUIExample + pod 'ReclaimInAppSdk', '~> 0.3.0' + + target 'GitPodSwiftUIExampleTests' do + inherit! :search_paths + # Pods for testing + end + + target 'GitPodSwiftUIExampleUITests' do + # Pods for testing + end + +end ``` - + +3. Run `pod install`. +4. Open the `*.xcworkspace` file to work on the project. Verify that you're opening MyApp.xcworkspace and not opening MyApp.xcodeproj. The .xcworkspace file has the CocoaPod dependencies, the .xcodeproj doesn't. + +For more info, check the [Reclaim Example - SwiftUI with CocoaPods](https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk/blob/main/Examples/SwiftUIWithPodExample/README.md) for a complete example of how to use the SDK in a SwiftUI application with CocoaPods. + + + + + + + + +```swift tabs="version" +.package(url: "https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git", from: "0.3.0") +``` + +```swift tabs="branch" +.package(url: "https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git", branch: "main") +``` + -Run `pod install` and open the `.xcworkspace` file. +#### Select a product: + +- ReclaimInAppSdk + +```swift +.product(name: "ReclaimInAppSdk", package: "reclaim-inapp-ios-sdk") +``` + + + + + +#### Build the project. + +1. If you have a `*.xcworkspace` then open `YourApp.xcworkspace` in Xcode. Verify that you're opening MyApp.xcworkspace and not opening MyApp.xcodeproj. The .xcworkspace file has the CocoaPod dependencies, the .xcodeproj doesn't. If you don't have a `*.xcworkspace` then open `YourApp.xcodeproj` in Xcode. +2. Select **Product** > **Build** or press `Cmd + B`. + + + + +1. Your build may fail due to an error like this: + +Xcode build error due to CocoaPods + +2. To fix this, open the `*.xcworkspace` file in Xcode. In your target's `Build Settings`, under `Build Options` Section, set `User Script Sandboxing` to `No` and build the project again. + +Xcode build error due to CocoaPods + + + + +### Update Environment Variables for XCScheme + + + + +1. Open your project in Xcode. +2. Click on the project target. +3. Click on the **Scheme** dropdown. + +Edit current xcscheme in Xcode + +4. Click on the **Edit Scheme** button. +5. Click on the **Run** tab. +6. Click on the **Arguments** tab and check the **Environment Variables** section. -**Troubleshooting**: If build fails, set **User Script Sandboxing** to **No** in Build Settings → Build Options. +Enable Debug executable in Xcode -## Performance Fix +7. Add the following environment variable: + - Key: `GODEBUG` + - Value: `asyncpreemptoff=1` +8. Click on the **Close** button in the dialog and build the project. +9. Run the app on a physical device. -To prevent performance issues on physical devices, add this environment variable: + + -1. Edit Scheme → Run → Arguments -2. Add environment variable: - - **Key**: `GODEBUG` - - **Value**: `asyncpreemptoff=1` \ No newline at end of file +Now continue with our [Usage guide](/ios-swift/usage). diff --git a/content/docs/ios-swift/usage.mdx b/content/docs/ios-swift/usage.mdx index 8561f1a..27343eb 100644 --- a/content/docs/ios-swift/usage.mdx +++ b/content/docs/ios-swift/usage.mdx @@ -5,6 +5,7 @@ description: Integrate Reclaim Protocol in Swift # Quickstart + ## Import module into your Swift file. ```swift @@ -56,57 +57,3 @@ The exception can be one of the following: - [SwiftUI Example](https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk/tree/main/Examples/SwiftUIExample) - [SwiftUI with CocoaPods](https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk/tree/main/Examples/SwiftUIWithPodExample) - -# Advance Options -## Complete Request Parameters - -```swift -let request = ReclaimVerification.Request.params( - try .init( - // Required - providerId: "YOUR_PROVIDER_ID", - - // Optional - appId: "YOUR_APP_ID", // Defaults to Info.plist - secret: "YOUR_APP_SECRET", // Defaults to Info.plist - - session: .init( // Reuse existing session - timestamp: "1234567890", - sessionId: "session-id", - signature: "signature" - ), - - contextString: "additional-context", // Additional context data - - parameters: [ // Custom provider parameters - "customParam": "value" - ], - - providerVersion: .init( // Specify provider version - resolvedVersion: "1.0.0", - versionExpression: "1.0.0" - ) - ) -) -``` - -## Alternative Methods - -### Start from URL - -```swift -let result = try await ReclaimVerification.startVerificationFromUrl( - "https://api.example.com/verification-request" -) -``` -## Customize Verification Flow - -```swift -try await ReclaimVerification.setOverrides( - appInfo: ReclaimOverrides.ReclaimAppInfo( - appName: "My Custom App", - appImageUrl: "https://example.com/logo.png" - ) - // Add other overrides as needed -) -``` \ No newline at end of file diff --git a/content/docs/js-sdk/verifying-proofs.mdx b/content/docs/js-sdk/verifying-proofs.mdx index 0c0c245..6a2658d 100644 --- a/content/docs/js-sdk/verifying-proofs.mdx +++ b/content/docs/js-sdk/verifying-proofs.mdx @@ -26,7 +26,7 @@ const proofs = JSON.parse(decodedBody); import { verifyProof } from '@reclaimprotocol/js-sdk'; ... - const isValid = await verifyProof(proofs[i]); // loop over proofs if multiple +const isValid = await verifyProof(proofs); ``` ## Extract the data diff --git a/content/docs/meta.json b/content/docs/meta.json index 9d0ee47..a19cbf9 100644 --- a/content/docs/meta.json +++ b/content/docs/meta.json @@ -6,8 +6,9 @@ "js-sdk", "react-native", "flutter", + "inapp-sdks", "ios-swift", - "android-kotlin", + "android", "onchain", "zkfetch", "browser-extension", diff --git a/content/docs/react-native/install/expo.mdx b/content/docs/react-native/install/expo.mdx new file mode 100644 index 0000000..57a771f --- /dev/null +++ b/content/docs/react-native/install/expo.mdx @@ -0,0 +1,96 @@ +--- +title: React Native Expo +description: Steps to install Reclaim InApp SDK on apps built with React Native Expo +--- + +import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; +import { BadgeGroup } from '@/app/components/badge'; +import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; + +## Installation + +```package-install +npm install @reclaimprotocol/inapp-rn-sdk +``` + +## Setup + +Add the Reclaim InApp Config Plugin to your `app.json`, `app.config.js`, or `app.config.ts`: + +```diff +{ + "plugins": [ ++ "@reclaimprotocol/inapp-rn-sdk", + // ... other plugins + ] +} +``` + + +This module contains custom native code and is **NOT supported by Expo Go**. You'll need to create a development build. + + +## Update Environment Variables for XCScheme + + + + +1. Open your project in Xcode. +2. Click on the project target. +3. Click on the **Scheme** dropdown. + +Edit current xcscheme in Xcode + +4. Click on the **Edit Scheme** button. +5. Click on the **Run** tab. +6. Click on the **Arguments** tab and check the **Environment Variables** section. + +Enable Debug executable in Xcode + +7. Add the following environment variable: + - Key: `GODEBUG` + - Value: `asyncpreemptoff=1` +8. Click on the **Close** button in the dialog and build the project. +9. Run the app on a physical device. + + + + + +## Building + + + + +```bash +# iOS +npx expo prebuild +npx expo run:ios + +# Android +npx expo prebuild +npx expo run:android +``` + + + + + +```bash +# Online builds +npx eas-cli build --profile development + +# Local builds +npx eas-cli build --profile development --local +``` + + + + +## Ready + +With the above steps completed, try running your project on any iOS device. You can now continue with our [React Native Get Started Guide](react-native/installation#using_reclaim). + + +Please be aware of a known incompatibility between ReclaimInAppSdk and the [expo-dev-client](https://www.npmjs.com/package/expo-dev-client) package on the iOS platform. We recommend temporarily removing [expo-dev-client](https://www.npmjs.com/package/expo-dev-client) from your project when you need to test or use ReclaimInAppSdk functionality on iOS. + diff --git a/content/docs/react-native/install/meta.json b/content/docs/react-native/install/meta.json new file mode 100644 index 0000000..4848761 --- /dev/null +++ b/content/docs/react-native/install/meta.json @@ -0,0 +1,7 @@ +{ + "title": "Installing InApp SDK", + "pages": [ + "no-framework", + "expo" + ] +} \ No newline at end of file diff --git a/content/docs/react-native/install/no-framework.mdx b/content/docs/react-native/install/no-framework.mdx new file mode 100644 index 0000000..e498381 --- /dev/null +++ b/content/docs/react-native/install/no-framework.mdx @@ -0,0 +1,212 @@ +--- +title: React Native without Framework +description: Steps to install Reclaim InApp SDK on apps built with React Native without a framework +--- + +import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; +import { BadgeGroup } from '@/app/components/badge'; +import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; + +## Installation + +```package-install +npm install @reclaimprotocol/inapp-rn-sdk +``` + +## Setup + +### Android Setup + +Add the following to your `android/app/src/main/AndroidManifest.xml` file under the `` tag: + +```xml + +``` + +add the following to the end of settings.gradle: + + +```groovy tabs="Groovy" +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) + String flutterStorageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com" + String reclaimStorageUrl = System.env.RECLAIM_STORAGE_BASE_URL ?: "https://reclaim-inapp-sdk.s3.ap-south-1.amazonaws.com/android/repo" + repositories { + google() + mavenCentral() + maven { + url "$reclaimStorageUrl" + } + maven { + url "$flutterStorageUrl/download.flutter.io" + } + } +} +``` + +```kotlin tabs="Kotlin" +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) + val flutterStorageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com" + val reclaimStorageUrl = System.env.RECLAIM_STORAGE_BASE_URL ?: "https://reclaim-inapp-sdk.s3.ap-south-1.amazonaws.com/android/repo" + repositories { + google() + mavenCentral() + maven("$reclaimStorageUrl") + maven("$flutterStorageUrl/download.flutter.io") + } +} +``` + + + +If the above doesn't work, alternatively add the following repositories to the relevant repositories block: + + +```groovy tabs="Groovy" +String flutterStorageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com" +String reclaimStorageUrl = System.env.RECLAIM_STORAGE_BASE_URL ?: "https://reclaim-inapp-sdk.s3.ap-south-1.amazonaws.com/android/repo" +// ... +maven { + url "$reclaimStorageUrl" +} +maven { + url "$flutterStorageUrl/download.flutter.io" +} +``` + +```kotlin tabs="Kotlin" +val flutterStorageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com" +val reclaimStorageUrl = System.env.RECLAIM_STORAGE_BASE_URL ?: "https://reclaim-inapp-sdk.s3.ap-south-1.amazonaws.com/android/repo" +// ... +maven("$reclaimStorageUrl") +maven("$flutterStorageUrl/download.flutter.io") +``` + + + +### iOS Setup + +#### Updating Podfile + +1. Make sure to have a platform declaration for your project in your `Podfile` with version 14.0 or higher. + +```ruby +platform :ios, '14.0' # or platform :ios, min_ios_version_supported +``` + +2. Run `pod install` inside the `ios/` directory of your project. + +```sh +cd ios/ +pod install +``` + +#### Update Environment Variables for XCScheme + + + + +1. Open your project in Xcode. +2. Click on the project target. +3. Click on the **Scheme** dropdown. + +Edit current xcscheme in Xcode + +4. Click on the **Edit Scheme** button. +5. Click on the **Run** tab. +6. Click on the **Arguments** tab and check the **Environment Variables** section. + +Enable Debug executable in Xcode + +7. Add the following environment variable: + - Key: `GODEBUG` + - Value: `asyncpreemptoff=1` +8. Click on the **Close** button in the dialog and build the project. +9. Run the app on a physical device. + + + + +## Ready + +With the above steps completed, try building & running your project on any iOS device. You can now continue with our [React Native Get Started Guide](react-native/installation#using_reclaim). + +## Advanced iOS Setup + + + + +If you need to use a specific version of the iOS SDK, you can override it in your `Podfile`: + +- This step is may only be required when facing issues with the resolved pod dependency. +- You can override the version of dependency when you wish to use a specific version of the SDK. + +You can add a declaration in your `Podfile` to install the SDK from cocoapods, or from a specific git tag, head, commit, or branch. Add the following to your `Podfile` to override SDK dependency: + + +```ruby tabs="Cocoapods (Recommended)" +# Cocoapods is the recommended way to install the SDK. +pod 'ReclaimInAppSdk', '~> x.y.z' +``` + +```ruby tabs="Git Tag" +pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :tag => '0.3.0' +``` + +```ruby tabs="Git Head" +pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git' +``` + +```ruby tabs="Git Commit" +pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :commit => '027e18b8b2365fd935e9e8585e31fa886c3af6ee' +``` + +```ruby tabs="Git Branch" +pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :branch => 'main' +``` + + + +- After adding the dependency, your podfile may look like this: + +```ruby +platform :ios, '13.0' + +# ... some podfile content (removed for brevity) + +target 'InappRnSdkExample' do + config = use_native_modules! + + use_react_native!( + :path => config[:reactNativePath], + :app_path => "#{Pod::Config.instance.installation_root}/.." + ) + + # This is the line that you may need to add in your podfile. + pod 'ReclaimInAppSdk', '~> 0.3.0' + + pre_install do |installer| + system("cd ../../ && npx bob build --target codegen") + end + + # ... rest of the podfile. (removed for brevity) +``` + + +After adding, you can then run: +```bash +cd ios/ +pod install +``` + +Continue to build and run your app as usual. + + + diff --git a/content/docs/react-native/installation.mdx b/content/docs/react-native/installation.mdx index c7b36ab..e493c09 100644 --- a/content/docs/react-native/installation.mdx +++ b/content/docs/react-native/installation.mdx @@ -1,190 +1,173 @@ --- -title: Installation -description: This SDK allows Reclaim Protocol to be triggered from your app, without changing context. +title: Get Started +description: Get Started to use Reclaim Protocol in your React Native app, without changing context. --- import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; import { BadgeGroup } from '@/app/components/badge'; import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; +## Add Reclaim to your React Native app -## Get an API Key -Setup your project using the [Get API Key guide](/api-key). +### @reclaimprotocol/inapp-rn-sdk + -# Using Expo +### Prerequisites -## Installation +1. Setup your project using the [Get API Key guide](/api-key). +2. A provider id that you've added to your app from [Reclaim Devtools](https://dev.reclaimprotocol.org/explore). -```package-install -npx expo install @reclaimprotocol/inapp-rn-sdk -``` +### Setup your app for using Reclaim InApp SDK -## Setup +Install Reclaim InApp SDKs to your React Native app if you haven't already done so. Choose the appropriate installation guide based on your project setup: -Add the Reclaim InApp Config Plugin to your `app.json`, `app.config.js`, or `app.config.ts`: +**For React Native projects without Expo:** +📖 [Installation Guide for React Native (No Framework)](/react-native/install/no-framework) -```diff -{ - "plugins": [ -+ "@reclaimprotocol/inapp-rn-sdk", - // ... other plugins - ] -} -``` +**For React Native Expo projects:** +📖 [Installation Guide for React Native Expo](/react-native/install/expo) - -This module contains custom native code and is **NOT supported by Expo Go**. You'll need to create a development build. - +## Example -## Building +- See the [Reclaim Example - React Native without Framework](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/samples/example_new_arch/README.md) for a complete example of how to use the SDK in a React Native application. +- See the [Reclaim Example - React Native Expo](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/samples/example_expo/README.md) for a complete example of how to use the SDK in a React Native Expo application. - - -```bash -# iOS -npx expo prebuild -npx expo run:ios +## Usage -# Android -npx expo prebuild -npx expo run:android -``` - +To use Reclaim InApp Sdk in your project, follow these steps: - -```bash -# Online builds -npx eas-cli build --profile development +1. Import the `@reclaimprotocol/inapp-rn-sdk` package in your project file. -# Local builds -npx eas-cli build --profile development --local +```js +import { ReclaimVerification } from '@reclaimprotocol/inapp-rn-sdk'; ``` - - - -## iOS Performance Fix -When running on iOS physical devices, add this environment variable to prevent performance issues: +2. Initialize the `ReclaimVerification` class to create an instance. -1. Open your project in Xcode -2. Edit Scheme → Run → Arguments tab -3. Add environment variable: - - **Key**: `GODEBUG` - - **Value**: `asyncpreemptoff=1` +```js +const reclaimVerification = new ReclaimVerification(); +``` ---- +### Starting Verification -# Without Using Expo +#### Quickly trying verifications with Reclaim -## Installation +Start the verification flow by simply providing an app id, secret and a provider id. -```package-install -npm install @reclaimprotocol/inapp-rn-sdk -``` + - You can use the `APP_ID` and `APP_SECRET` that you received when you setup API key using [this guide](/api-key) + - The `PROVIDER_ID` is identifier for the proof provider you want your users to generate. You can see all the [available providers here](https://dev.reclaimprotocol.org/explore). -Alternatively, install directly from GitHub: - -```bash -npm install git+https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk.git +```js +const verificationResult = await reclaimVerification.startVerification({ + appId: config.REACT_APP_RECLAIM_APP_ID ?? '', + secret: config.REACT_APP_RECLAIM_APP_SECRET ?? '', + providerId: providerId, +}); ``` -## Android Setup +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. -### 1. Add Activity to AndroidManifest.xml +#### Recommended way to start verification -Add this inside the `` tag in `android/app/src/main/AndroidManifest.xml`: +We highly recommend that you create a verification session on your backend server using our [JS SDK](/js-sdk/preparing-request#send-back-the-proof-request-object-to-the-frontend). This way, you can avoid exposing your `APP_SECRET` in your mobile app. -```xml - -``` +You can export the session generated at your backend using `request.toJsonString()`. Then, you can use this exported session to start the verification in your React Native app. -### 2. Add Repositories - -Add these repositories to your `android/settings.gradle`: - -```groovy -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) - String flutterStorageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com" - String reclaimStorageUrl = System.env.RECLAIM_STORAGE_BASE_URL ?: "https://reclaim-inapp-sdk.s3.ap-south-1.amazonaws.com/android/repo" - repositories { - google() - mavenCentral() - maven { - url "$reclaimStorageUrl" - } - maven { - url "$flutterStorageUrl/download.flutter.io" - } - } -} -``` +```js +const verificationResult = await reclaimVerification.startVerificationFromJson(JSON.parse(requestJsonString)); +``` - -If the above doesn't work, try adding the repositories to your root `build.gradle` or app-level `build.gradle` in the `allprojects` section. - +### Verifying the Result -## iOS Setup +After the verification is completed, you can verify the proofs from this result on your backend server using our [JS SDK](/js-sdk/verifying-proofs#verify-the-proof). -### 1. Set Minimum iOS Version +```js +import { verifyProof } from "@reclaimprotocol/js-sdk"; -Ensure your `ios/Podfile` has iOS 13.0 or higher: +// Important: This should happen on your backend server +verifyProof(verificationResult.proofs); +``` -```ruby -platform :ios, '13.0' +### Exception Handling + +If the verification ends with an exception, the exception is thrown as a [ReclaimVerification.ReclaimVerificationException] object. + +Following is an example of how to handle the exception using [error.type]: + +```js +try { + // ... start verification +} catch (error) { + if (error instanceof ReclaimVerification.ReclaimVerificationException) { + switch (error.type) { + case ReclaimVerification.ExceptionType.Cancelled: + Snackbar.show({ + text: 'Verification cancelled', + duration: Snackbar.LENGTH_LONG, + }); + break; + case ReclaimVerification.ExceptionType.Dismissed: + Snackbar.show({ + text: 'Verification dismissed', + duration: Snackbar.LENGTH_LONG, + }); + break; + case ReclaimVerification.ExceptionType.SessionExpired: + Snackbar.show({ + text: 'Verification session expired', + duration: Snackbar.LENGTH_LONG, + }); + break; + case ReclaimVerification.ExceptionType.Failed: + default: + Snackbar.show({ + text: 'Verification failed', + duration: Snackbar.LENGTH_LONG, + }); + } + } else { + Snackbar.show({ + text: error instanceof Error ? error.message : 'An unknown verification error occurred', + duration: Snackbar.LENGTH_LONG, + }); + } +} ``` -### 2. Install Pods +This error also contains `sessionId`, `reason`, and `innerError` that can be used to get more details about the occurred error. -```bash -cd ios/ -pod install +```js +error.sessionId +error.reason +error.innerError ``` -### 3. Fix Performance on Physical Devices +If you need more help, check out the [Troubleshooting guide](/react-native/troubleshooting). -Add this environment variable in your Xcode scheme to prevent performance issues on physical devices: +## Next Steps -1. Open `*.xcworkspace` in Xcode -2. Edit Scheme → Run → Arguments -3. Add environment variable: - - **Key**: `GODEBUG` - - **Value**: `asyncpreemptoff=1` +- Explore more about [Proof Providers](https://dev.reclaimprotocol.org/explore) that you can integrate with your app. -## Advanced iOS Setup +### Advanced Usage - - +You can customize the verification flow with options, and, as an advanced use—set up overrides or use authentication with the attestor. Learn more from [the Usage documentation](/inapp-sdks/advanced/intro). -If you need to use a specific version of the iOS SDK, you can override it in your `Podfile`: +### Contributing -**From CocoaPods (Recommended):** -```ruby -pod 'ReclaimInAppSdk', '~> 0.18.0' -``` +Contributions are welcome! Please feel free to submit a Pull Request. -**From Git Tag:** -```ruby -pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :tag => '0.18.0' -``` +### Issues and Feedback -**From Git HEAD:** -```ruby -pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git' -``` +Please feel free to file feature requests and bugs at the issue tracker of InApp sdks. Don't hesitate to contact us if you need any help ;) -After adding, run: -```bash -cd ios/ -pod install -``` +### Stay Updated - - +- Join our [Telegram community](https://t.me/protocolreclaim) +- Follow [@reclaimprotocol](https://twitter.com/reclaimprotocol) on Twitter +- Watch our [GitHub repository](https://github.com/reclaimprotocol) diff --git a/content/docs/react-native/meta.json b/content/docs/react-native/meta.json index 7d3dce7..1393f3d 100644 --- a/content/docs/react-native/meta.json +++ b/content/docs/react-native/meta.json @@ -2,6 +2,8 @@ "title": "React Native SDK", "pages": [ "installation", - "usage" + "install", + "troubleshooting", + "advanced-usage" ] } \ No newline at end of file diff --git a/content/docs/react-native/troubleshooting.mdx b/content/docs/react-native/troubleshooting.mdx new file mode 100644 index 0000000..9091e23 --- /dev/null +++ b/content/docs/react-native/troubleshooting.mdx @@ -0,0 +1,103 @@ +--- +title: Troubleshooting problems +description: Figuring out common issues when integrating Reclaim InApp SDK in React Native apps +--- + +## Common Issues and Solutions + +If you encounter issues while integrating Reclaim InApp SDK into your React Native application, here are some common troubleshooting steps to help you resolve them: + +### iOS build issues + +Incase you get errors which say `CocoaPods could not find compatible versions for pod "ReclaimInAppSdk"`, run the following in your project's `ios/` directory: + +```sh +bundle exec pod update ReclaimInAppSdk +# or +pod update ReclaimInAppSdk +``` + +### Compatibility Notice: expo-dev-client on iOS + +Please be aware of a known incompatibility between ReclaimInAppSdk and the [`expo-dev-client`](https://www.npmjs.com/package/expo-dev-client) package on the iOS platform. + +When both packages are present in your iOS application, critical network requests from ReclaimInAppSdk may fail with a request timeout error (i.e `Http failed. Checking if we can retry..\nNSErrorClientException: The request timed out.`). + +Our team is investigating this issue to find a solution. In the meantime, we recommend temporarily removing expo-dev-client from your project when you need to test or use ReclaimInAppSdk functionality on iOS. + +### UI immediately closes + +The verification likely ended with an exception, the exception is thrown as a [ReclaimVerification.ReclaimVerificationException] object. + +A common reason behind this could be incorrect configuration used to start the verification like using a provider ID that is included for use for your app which can be fixed by ensuring the provider ID is correctly set up in your [Reclaim Devtools Application dashboard](https://dev.reclaimprotocol.org/). + +To get more details about error, following is an example of how to handle the exception using [error.type]: + +```js +try { + // ... start verification +} catch (error) { + if (error instanceof ReclaimVerification.ReclaimVerificationException) { + switch (error.type) { + case ReclaimVerification.ExceptionType.Cancelled: + Snackbar.show({ + text: 'Verification cancelled', + duration: Snackbar.LENGTH_LONG, + }); + break; + case ReclaimVerification.ExceptionType.Dismissed: + Snackbar.show({ + text: 'Verification dismissed', + duration: Snackbar.LENGTH_LONG, + }); + break; + case ReclaimVerification.ExceptionType.SessionExpired: + Snackbar.show({ + text: 'Verification session expired', + duration: Snackbar.LENGTH_LONG, + }); + break; + case ReclaimVerification.ExceptionType.Failed: + default: + Snackbar.show({ + text: 'Verification failed', + duration: Snackbar.LENGTH_LONG, + }); + } + } else { + Snackbar.show({ + text: error instanceof Error ? error.message : 'An unknown verification error occurred', + duration: Snackbar.LENGTH_LONG, + }); + } +} +``` + +This error also contains `sessionId`, `reason`, and `innerError` that can be used to get more details about the occurred error. + +```js +error.sessionId +error.reason +error.innerError +``` + +### Cronet errors on android without play services + +On android devices which don't have play services, you may get following errors in Android logs: `java.lang.RuntimeException: All available Cronet providers are disabled. A provider should be enabled before it can be used.`, `Google-Play-Services-Cronet-Provider is unavailable.`. This is because the Reclaim InApp SDK depends on cronet for making http requests. + +To fix this, you need to use embedded cronet in your android app by adding the following dependency in your build.gradle dependencies block: + +```gradle +dependencies { + // ... other dependencies (not shown for brevity) + // Use embedded cronet + implementation("org.chromium.net:cronet-embedded:119.6045.31") +} +``` + +## Need More Help? + +If you need further assistance, please reach out to our support team or visit our [Telegram community](https://t.me/protocolreclaim) for help from other developers. + +- Join our [Telegram community](https://t.me/protocolreclaim) +- Open an issue on our [GitHub repository](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/issues)