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.

Add the dependency:

dependencies {
    implementation("com.insurely:insurely-android-sdk:1.2.2")
}

mavenCentral() is already in most projects' repository list; if it is not, add it in settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}

Sync Gradle, and the SDK is available under import com.insurely.blocks.sdk.*. Gradle resolves the SDK's own dependencies from its POM, so there is nothing else to declare.

Upgrading from the AAR

If you integrated before 1.2.2, the SDK was distributed as an AAR you vendored or downloaded, and you had to declare its ktor and kotlinx-serialization dependencies yourself. Switching to the Maven coordinate lets you delete the vendored AAR, the flatDir repository entry and all six of those dependency declarations. The binary is unchanged.

The AAR is still attached to every release for builds that cannot reach Maven Central. That path does still require declaring the transitive dependencies by hand, and the repository README lists them.

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