Mobile SDKs

Insurely provides three SDKs for embedding the Prebuilt UI in a native app: Android, iOS and React Native.

Each SDK loads the Prebuilt UI in a native web view and exposes a single view component plus a small set of configuration, prefill and event APIs, so you do not have to build the webview integration yourself.

Requirements

SDKRequirements
AndroidAndroid API level 24 (Android 7.0) or later, Kotlin 1.9 or later, Jetpack Compose
iOSiOS 15.0 or later, Xcode 15.0 or later, Swift 5.10 or later
React NativeReact Native 0.76 or later, New Architecture only. iOS 15 or later, Android minSdk 24

Installation

The SDK can be installed three ways. All produce an identical, signed binary in your app, they differ only in how the framework reaches your project.

  • Swift Package Manager (remote) when GitHub is reachable at build time and you want SPM to manage version updates. Add the repository in File → Add Package Dependencies…, then add the InsurelySDK library to your target with Embed & Sign.
  • Swift Package Manager (local clone) when you want to vendor the SDK for reproducibility, build in air-gapped CI, or pin to a specific commit. Clone the repository, then File → Add Package Dependencies… → Add Local….
  • Manual framework integration when you do not use SPM. Download InsurelySDK.xcframework.zip from the latest release, unzip it, drag it into your project, and set Embed & Sign.

Step-by-step instructions for each method are in the repository README.

The SDK can be installed two ways. Both produce an identical AAR in your app, they differ only in how it reaches your project.

  • Vendored clone (recommended) when you want to vendor the SDK in your repository, build in air-gapped CI, or pin to a specific commit. Clone the repository, add it as a flatDir repository in settings.gradle.kts, and reference InsurelySDK-release.aar from your app module.
  • Direct AAR download when you would rather drop a versioned binary into your project. Download the AAR from the latest release into your app module's libs/ directory and point flatDir at it.

Step-by-step instructions for both methods are in the repository README.

Declare the transitive dependencies

An AAR resolved through flatDir does not bring its own transitive dependencies, so your app has to declare them explicitly:

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
implementation("io.ktor:ktor-client-core:2.3.10")
implementation("io.ktor:ktor-client-cio:2.3.10")
implementation("io.ktor:ktor-client-logging:2.3.10")
implementation("io.ktor:ktor-client-content-negotiation:2.3.10")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.10")

Pin the exact versions listed for the SDK version you are integrating. Without them the SDK compiles successfully but crashes at runtime with NoClassDefFoundError the first time the web view is shown.

Install the package and its react-native-webview peer dependency:

npx expo install @insurely/react-native-sdk react-native-webview

In a bare React Native app:

npm install @insurely/react-native-sdk react-native-webview
cd ios && pod install

If you need Swedish BankID, there is native setup on top of that, because the BankID app returns the user to your app through a custom URL scheme. On Expo the bundled config plugin handles all of it, so you never edit Info.plist or AndroidManifest.xml by hand. Add it to app.json, passing the scheme your app uses to receive the user back:

{
  "expo": {
    "scheme": "myapp",
    "plugins": [
      ["@insurely/react-native-sdk/app.plugin.js", { "bankIdRedirectScheme": "myapp" }]
    ]
  }
}

Rebuild afterwards. Editing app.json alone changes nothing until the next prebuild.

Without Expo there is no plugin to run, so those entries go in by hand. The SDK ships a checker that reports exactly which are missing and prints the block to paste in:

npx insurely-sdk-doctor

The getting started guide has the full bare React Native setup, the event model and the imperative API.

Quickstart

The whole SDK is reached through a single view. Insurely provides your Customer ID and Config name during onboarding, see Introduction.

import SwiftUI
import InsurelySDK

struct InsurelyScreen: View {
    var body: some View {
        InsurelyView(
            context: InsurelyContext(environment: .production),
            configuration: InsurelyConfiguration(
                customerId: "your-customer-id",
                configName: "your-config-name"
            )
        )
        .onInsurelyResults { results in
            // Handle the collected data when the flow completes.
            print(results.data)
        }
        .onInsurelyError { error in
            switch error {
            case .failedToOpenBankID:
                // Optionally surface a fallback UI.
                break
            @unknown default:
                break
            }
        }
    }
}
import androidx.compose.runtime.Composable
import com.insurely.blocks.sdk.InsurelyView
import com.insurely.blocks.sdk.config.InsurelyConfig
import com.insurely.blocks.sdk.config.InsurelyEnvironment
import com.insurely.blocks.sdk.config.InsurelySettings

@Composable
fun InsurelyScreen() {
    InsurelyView(
        settings = InsurelySettings(
            environment = InsurelyEnvironment.Prod,
            config = InsurelyConfig(
                customerId = "your-customer-id",
                configName = "your-config-name",
            ),
        ),
        onResultsReceived = { results ->
            // Handle the collected data when the flow completes.
        },
        onEventReceived = { event ->
            // Handle SDK events (collection status, page views, etc.).
        },
        onErrorReceived = { error ->
            // Handle SDK errors.
        },
    )
}

Use InsurelyEnvironment.Test while developing against the test environment.

import { InsurelyView, type InsurelyConfig } from '@insurely/react-native-sdk';

const config: InsurelyConfig = {
  customerId: 'your-customer-id',
  configName: 'your-config-name',
  language: 'sv',
};

<InsurelyView
  style={{ flex: 1 }}
  environment="test"
  config={config}
  bankIdRedirectUrl="myapp:///"
  onResults={(results) => console.log(results.data)}
  onError={(error) => console.warn(error)}
  onEvent={(event) => console.log(event)}
/>;

This reaches the company selection screen. environment selects the Blocks deployment and takes 'production', 'staging' or 'test', or { url: 'https://...' } to point at a specific one.

bankIdRedirectUrl only matters if you need Swedish BankID. It is the scheme the BankID app uses to return the user to your app.

Building your own instead

If you would rather set the webview up yourself instead of using an SDK, the mobile webview guide covers the full iOS and Android integration.

Last updated on