# Flutter Plugin

The Flutter Plugin initialization much depends on the mode your dashboard operates on. Use the documention below only if your dashbord is still in Flows/Levels mode, otherwise please refer to the main documentation.

# Backend routines

In order to embed our MobileSDK you have to complete a couple of preparation steps on your backend and use the results to pass into the MobileSDK initialization:

# Step 1: Applicant Flow

Set up your applicant flow or pick a predefined one (e.g. msdk-basic-kyc) in the dashboard

# Step 2: Access Token

Generate an access token that is associated with the externalUserId - a user id in your system. This is needed for constraining the access token to only one applicant.

curl -X POST \
  'https://test-api.sumsub.com/resources/accessTokens?userId=SomeUserIdInYourSystem&ttlInSecs=600' \
    -H 'Accept: application/json'

# Step 3: All done!

Now you can initialize the Mobile SDK.

# Setup

# Regular Flow

import 'package:flutter_idensic_mobile_sdk_plugin/flutter_idensic_mobile_sdk_plugin.dart';

void launchSDK() async {

  final String apiUrl = "https://test-api.sumsub.com"; // https://api.sumsub.com
  final String flowName = "msdk-basic-kyc"; // or set up your own with the dashboard
  final String accessToken = "your_access_token"; // generate one on the backend

  final onTokenExpiration = () async {
    // call your backend to fetch a new access token (this is just an example)
    return Future<String>.delayed(Duration(seconds: 2), () => "new_access_token");

  final SNSStatusChangedHandler onStatusChanged = (SNSMobileSDKStatus newStatus, SNSMobileSDKStatus prevStatus) {
    print("The SDK status was changed: $prevStatus -> $newStatus");

  final snsMobileSDK = SNSMobileSDK.builder(apiUrl, flowName)
    .withAccessToken(accessToken, onTokenExpiration)
    .withHandlers(onStatusChanged: onStatusChanged)
    .withSupportEmail("[email protected]")
    .withLocale(Locale("en")) // Optional, for cases when you need to override system locale

  final SNSMobileSDKResult result = await snsMobileSDK.launch();

  print("Completed with result: $result");

The return type of the snsMobileSDK.launch() method is the Future of SNSMobileSDKResult type. Use it to determine the SDK status upon its closure.

Here is an example of the result:

  success: false,
  status: SNSMobileSDKStatus.Failed,
  errorType: SNSMobileSDKErrorType.Unauthorized,
  errorMsg: "Unauthorized access with accessToken=[your access token]",
  actionResult: null

Please find a detailed description in the main documentation.

# Action Flow

In order to run the SDK in applicant action mode, you need to create an applicant flow of Applicant actions type in the dashboard and specify its name as the flowName initialization parameter. Also, it'll be required to make an Access Token not only with the userId parameter, but with the externalActionId one as well.

Aside from the notes above, you manage the sdk the same way that you do with regular flows, the only difference is in how you get the action's result (please see the main documentation for further details).

Last Updated: 9/28/2021, 3:33:55 PM