# SumSub Flutter Plugin

# Latest Release

Version 1.13.1

# Installation

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_idensic_mobile_sdk_plugin: ^1.13.1

Then run:

flutter pub get

# iOS

  1. Update ios/Podfile as follows:
platform :ios, '9.0'

source 'https://cdn.cocoapods.org/'
source 'https://github.com/SumSubstance/Specs.git'
  1. Update Info.plist to create a description for the usage of the camera, microphone and the photo library:
plutil -insert "NSCameraUsageDescription" -string "Let us take a photo" ios/Runner/Info.plist
plutil -insert "NSMicrophoneUsageDescription" -string "Time to record a video" ios/Runner/Info.plist
plutil -insert "NSPhotoLibraryUsageDescription" -string "Let us pick a photo" ios/Runner/Info.plist

# Usage

Add to lib/main.dart:

# Setup

import 'package:flutter_idensic_mobile_sdk_plugin/flutter_idensic_mobile_sdk_plugin.dart';

void launchSNSMobileSDK() 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)
    .withDebug(true)
    .withSupportEmail("[email protected]")
    .withLocale(Locale("en")) // Optional, for cases when you need to override system locale
    .build();

  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:

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

Please find a detailed description below.

# Launch

Next, you are able to use the launchSNSMobileSDK(), as defined above, in order to launch the SDK.

For example:

      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
...

            Container(
              alignment: Alignment.center,
              child: RaisedButton(onPressed: () => launchSNSMobileSDK(),
              child: Text("Launch SumSub SDK")),
            ),

...
          ],
        ),
      ),

# Dismission

Normally, the user closes the SDK themselves, but if you need to do it programmatically, here is the method for it:

snsMobileSDK.dismiss()

# API Reference

# SNSMobileSDKResult

An object describing the result of the last SDK launch:

Field Type Description
success bool The boolean value indicates whether there was an error at the moment the SDK was closed. Use errorType and errorMsg to see the reasons of the error, if there is one
status SNSMobileSDKStatus SDK status expressed with SNSMobileSDKStatus enum
errorType SNSMobileSDKErrorType? Error reason expressed with SNSMobileSDKErrorType enum
errorMsg String? A verbose error description
actionResult SNSMobileSDKActionResult? Describes the result of the latest applicant action's invocation, if any

# SNSMobileSDKStatus

An enum describing the possible SDK statuses:

Case Description
Ready SDK is initialized and ready to be presented
Failed SDK has failed for some reason (see errorType and errorMsg for details)
Initial No verification steps have been passed yet
Incomplete Some, but not all, of the verification steps have been completed
Pending Verification is pending
TemporarilyDeclined Applicant has been declined temporarily
FinallyRejected Applicant has been finally rejected
Approved Applicant has been approved
ActionCompleted Applicant action has been completed

# SNSMobileSDKErrorType

An enum describing the possible reasons for failure:

Case Description
Unknown Unknown or no failure
InvalidParameters An attempt to setup with invalid parameters
Unauthorized Unauthorized access detected (most likely accessToken is invalid or expired and couldn't be refreshed)
InitialLoadingFailed Initial loading from the backend has failed
ApplicantNotFound No applicant can be found for the given parameters
ApplicantMisconfigured Applicant has been found, but is misconfigured (most likely they lacks ID Docs)
InititlizationError An initialization error has occured
NetworkError A network error has occured (the user will be presented with the Network Oops screen)
UnexpectedError An unexpected error has occured (the user will be presented with the Fatal Oops screen)

# SNSMobileSDKActionResult

When an applicant action, is completed the status will be set to ActionCompleted and the result structure will contain the actionResult field that describes the outcome of the last invocation:

SNSMobileSDKResult(
  success: true, 
  status: SNSMobileSDKStatus.ActionCompleted, 
  errorType: null, 
  errorMsg: null, 
  actionResult: SNSMobileSDKActionResult(
    actionId: "5f9186b8aee05c5fa1ae11bb", 
    answer: SNSMobileSDKAnswerType.Green
  )
)

An empty value of actionResult.answer means that the action was cancelled.

Field Type Description
actionId String Applicant action identifier to check the results against the server
answer SNSMobileSDKAnswerType? Overall result expressed with SNSMobileSDKAnswerType enum

# SNSMobileSDKAnswerType

An enum describing the possible answers:

Case Description
Green Positive answer
Red Negative answer
Yellow Neutral answer
Error Something went wrong
Ignored The check had not ever been started
Last Updated: 10/23/2020, 2:36:10 PM