# SumSub Flutter Plugin

# Installation

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

dependencies:
  flutter_idensic_mobile_sdk_plugin: ^1.10.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 have description for the camera and microphone usage:
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

# Usage

Add to lib/main.dart:

# Setup

import 'package:flutter_idensic_mobile_sdk_plugin/idensic_mobile_sdk.dart';

void launchSNSMobileSDK() async {

  final String apiUrl = "https://test-api.sumsub.com"; // https://api.sumsub.com
  final String accessToken = "your access token";

  final onTokenExpiration = () async {
    // call your backend to fetch a new access token (this is just an example)
    Future<String>.delayed(Duration(seconds: 2), () {
      return "_act-66d142f3-88c1-4af6-ae6e-38578cc21c97";
    });
  };

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

  final snsMobileSDK = SNSMobileSDK.Builder(apiUrl)
    .withAccessToken(accessToken, onTokenExpiration)
    .withDebug(true)
    .withHandlers(onStatusChanged: onStatusChanged)
    .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 at the moment it has been closed.

Here is an example of the result:

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

Please find the detailed description below.

# Launch

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

In example:

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

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

...
          ],
        ),
      ),

# API Reference

# SNSMobileSDKResult

An object described the result of the last sdk launch:

Field Type Description
success bool The boolean value indicates if there was an error on the moment the sdk is closed. Use errorType and errorMsg to see the reasons of the error if any
status SNSMobileSDKStatus SDK status expressed with SNSMobileSDKStatus enum
errorType SNSMobileSDKErrorType? Error reason expressed with SNSMobileSDKErrorType enum
errorMsg String? A verbose error description

# SNSMobileSDKStatus

An enum described the possible sdk statuses:

Case Description
Ready SDK is initialized and ready to be presented
Failed SDK fails for some reasons (see failReason and verboseStatus for details)
Initial No verification steps are passed yet
Incomplete Some but not all of the verification steps have been passed over
Pending Verification is pending
TemporarilyDeclined Applicant has been declined temporarily
FinallyRejected Applicant has been finally rejected
Approved Applicant has been approved

# SNSMobileSDKErrorType

An enum described the possible fail reasons:

Case Description
Unknown Unknown or no fail
InvalidParameters An attempt to setup with invalid parameters
Unauthorized Unauthorized access detected (most likely accessToken is invalid or expired and had failed to be refreshed)
InitialLoadingFailed Initial loading from backend is failed
ApplicantNotFound No applicant is found for the given parameters
ApplicantMisconfigured Applicant is found, but is misconfigured (most likely lacks of idDocs)
NetworkError A network error occured (the user will be presented with Network Oops screen)
UnexpectedError Some unexpected error occured (the user will be presented with Fatal Oops screen)
Last Updated: 6/17/2020, 3:08:14 PM