Flutter plugin
Start your integration with Flutter plugin.
Latest release: Version 1.38.1 (Changelog)
Installation
- Add the following dependency to your package
pubspec.yaml
file.
dependencies:
flutter_idensic_mobile_sdk_plugin: ^1.38.1
- Run the following command.
flutter pub get
Android
Important
Use Kotlin 1.9.25 and API level 23 (Android 5.0) or higher in your Android project.
iOS
Important
Disable bitcode for the whole project and for the
flutter_idensic_mobile_sdk_plugin
target underPods
project, in particular (Pods -> flutter_idensic_mobile_sdk_plugin -> Build Settings -> Enable Bitcode -> No
).
- Update
ios/Podfile
as follows.
platform :ios, '12.0'
source 'https://cdn.cocoapods.org/'
source 'https://github.com/SumSubstance/Specs.git'
# Enable MRTDReader (NFC) module
#ENV['IDENSIC_WITH_MRTDREADER'] = 'true'
# Enable VideoIdent module
#ENV['IDENSIC_WITH_VIDEOIDENT'] = 'true'
# Enable EID module
#ENV['IDENSIC_WITH_EID'] = 'true'
- Update
Info.plist
to have a description for the usage of the camera, microphone, photo library, and geolocation.
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
plutil -insert "NSLocationWhenInUseUsageDescription" -string "Please provide us with your geolocation data to prove your current location" ios/Runner/Info.plist
Modules
MRTDReader (NFC)
The MRTDReader
is an optional module that allows the SDK to detect and read the electronic chips placed on MRTD documents via NFC.
Android
To enable MRTDReader
module on Android, add the following dependency to your 'android/app/build.gradle'
file.
dependencies {
...
// add dependency to enable MRTDReader
implementation "com.sumsub.sns:idensic-mobile-sdk-nfc:1.37.1"
...
}
iOS
To enable MRTDReader
module for iOS, follow the instructions below:
- Update
ios/Podfile
.
# Enable MRTDReader (NFC) module
ENV['IDENSIC_WITH_MRTDREADER'] = 'true'
- Open up the iOS project in XCode.
xed ios/
- Turn on the
Near Field Communication Tag Reading
capability for your project target. - Add to the application
Info.plist
file.
<key>NFCReaderUsageDescription</key>
<string>Let us scan the document for more precise recognition</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
<string>A0000002472001</string>
<string>00000000000000</string>
</array>
VideoIdent
The VideoIdent
is an optional module that is required only if you are going to use the Video identification during the verification flow.
Android
To enable VideoIdent
module on Android, add the following dependency to your 'android/app/build.gradle'
file.
dependencies {
...
// add dependency to enable videoident
implementation "com.sumsub.sns:idensic-mobile-sdk-videoident:1.37.1"
...
}
iOS
To enable VideoIdent
module on iOS:
- Update
ios/Podfile
.
# VideoIdent module requires iOS 12.2+
platform :ios, '12.2'
# Enable VideoIdent module
ENV['IDENSIC_WITH_VIDEOIDENT'] = 'true'
- Open up the iOS project in XCode.
xed ios/
- Add
Background mode
capability for your project target and select theAudio, AirPlay, and Picture in Picture
option required for the video call not to be broken when the application goes into the background.
eID
The EID
is an optional module required only if you are going to use "eID Verification" during the verification flow.
Android
To enable EID
module on Android, add the following dependency to your 'android/app/build.gradle'
file.
dependencies {
...
// add dependency to enable EID
implementation "com.sumsub.sns:idensic-mobile-sdk-eid:1.37.1"
...
}
iOS
To enable EID
module on iOS:
- Update
ios/Podfile
.
# Enable EID module
ENV['IDENSIC_WITH_EID'] = 'true'
- Open up the iOS project in XCode.
xed ios/
- Turn on the
Near Field Communication Tag Reading
capability for your project target. - Add to the application
Info.plist
file.
<key>NFCReaderUsageDescription</key>
<string>Let us scan the eID card to verify your identity</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
<string>E80704007F00070302</string>
</array>
Usage
Important
Before launching, make sure you have configured your verification level and access token.
Setup
import 'package:flutter_idensic_mobile_sdk_plugin/flutter_idensic_mobile_sdk_plugin.dart';
void launchSDK() async {
// From your backend get an access token for the applicant to be verified.
// The token must be generated with `levelName` and `userId`,
// where `levelName` is the name of a level configured in your dashboard.
//
// The sdk will work in the production or in the sandbox environment
// depend on which one the `accessToken` has been generated on.
//
final String accessToken = "your_access_token";
// The access token has a limited lifespan and when it's expired, you must provide another one.
// So be prepared to get a new token from your 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), () => "your new access token");
};
final SNSStatusChangedHandler onStatusChanged = (SNSMobileSDKStatus newStatus, SNSMobileSDKStatus prevStatus) {
print("The SDK status was changed: $prevStatus -> $newStatus");
};
final snsMobileSDK = SNSMobileSDK.init(accessToken, onTokenExpiration)
.withHandlers( // optional handlers
onStatusChanged: onStatusChanged
)
.withDebug(true) // set debug mode if required
.withLocale(Locale("en")) // optional, for cases when you need to override the 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
)
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: ElevatedButton(onPressed: () => launchSDK(),
child: Text("Launch Sumsub SDK")),
),
...
],
),
),
Dismissal
By default, once the applicant is approved, the SDK will be dismissed in 3 seconds automatically. You can adjust this time interval or switch the automatic dismissal off by setting the value to zero.
snsMobileSDK.withAutoCloseOnApprove(0)
Also, in case you need to close the SDK programmatically, here is what you can do.
snsMobileSDK.dismiss()
Advanced
Configuration
If it is required, you could provide an email and/or phone number that will be assigned to the applicant initially.
.withApplicantConf({
"email": "...",
"phone": "..."
})
Preferred Documents
For IDENTITY*
steps, it is possible to specify the preferred country and document type to be selected automatically, bypassing the DocType Selector
screen. Note that the parameters provided will be applied only if the corresponding combination of country and idDocType
is allowed at the step according to the level configuration.
.withPreferredDocumentDefinitions({
"IDENTITY": {
"idDocType":"PASSPORT",
"country":"USA"
},
"IDENTITY2": {
"idDocType":"DRIVERS",
"country":"FRA"
}
})
Disable Google ML Kit
Important
This is an Android-specific feature.
The SumSub SDK uses Google ML Kit face detection library if it is available with the application, and built-in Android face detection otherwise. You can disable using ML Kit even if it is available.
.withDisableMLKit(true)
Localization
You can customize or localize the texts used within the SDK through the MSDK Translations tool in the dashboard.
The language of the texts will be set according to the system locale, but you could override it with the locale you desire:
.withLocale(Locale("en"))
For a complete list of supported locales, see this article.
Strings
In addition to the MSDK Translations tool and .withLocale
, you can use .withStrings
option that allows you to define the strings locally.
This may be helpful for iOS apps if you would like to avoid the Wordless Oops screen that could be rendered in case the network happens to be down during the SDK initialization, and force the SDK to draw the Network Oops instead.
.withStrings({
"sns_oops_network_title": "Oops! Seems like the network is down.",
"sns_oops_network_html": "Please check your internet connection and try again.",
"sns_oops_action_retry": "Try again",
})
Note that .withLocale
does not affect these strings, thus it is up to you to use the required localization.
Analytics
The SDK collects and sends usage data to Sumsub servers. We do not track any sensitive data. Only general usage statistics are sent to us. It includes screen navigation events, UI controls interaction events, and so on.
We interpret the usage data in order to improve Sumsub. None of the data is sold or transferred to third parties, and we do not use it for advertising.
If you still want to disable this feature, you can use the following to do this.
.withAnalyticsEnabled(false)
Events
Various events happening along the processing could be delivered into an optional onEvent
handler.
final SNSEventHandler onEvent = (SNSMobileSDKEvent event) {
print("onEvent: $event");
};
final snsMobileSDK = SNSMobileSDK.init(accessToken, onTokenExpiration)
.withHandlers(
onEvent: onEvent
)
Each Event has eventType
and some parameters packed into payload
map, for example.
SNSMobileSDKEvent(
eventType: "StepInitiated",
payload: {
"idDocSetType": "IDENTITY"
}
)
Possible events
eventType | payload | Description |
---|---|---|
"ApplicantLoaded" | { | Applicant $applicantId has been loaded. |
"StepInitiated" | { | Step $idDocSetType has been initiated. |
"StepCompleted" | { | Step $idDocSetType has been fulfilled or cancelled. |
"Analytics" | { | Analytics event $eventName has occurred. |
Applicant Actions
To run the iOS SDK in Applicant actions mode, you need to have:
- A verification level with the Applicant actions type.
- An access token created with the
userId
,levelName
, andexternalActionId
parameters.
Aside from the notes above, use the SDK the same way that you do with regular levels.
Important
The
Payment methods
step is not supported at the moment.
API Reference
SNSMobileSDKResult
An object describing the result of the last SDK launch:
Field | Type | Description |
---|---|---|
success | bool | 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? | Verbose error description. |
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. |
SNSMobileSDKErrorType
An enum describing the possible reasons for failure:
Case | Description |
---|---|
Unknown | Unknown or no failure. |
InvalidParameters | Attempt to set up with invalid parameters. |
Unauthorized | Unauthorized access detected (most likely accessToken is invalid or expired and could not 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). |
NetworkError | Network error has occurred (the user will be presented with the Network Oops screen). |
UnexpectedError | Unexpected error has occurred (the user will be presented with the Fatal Oops screen). |
SNSMobileSDKEvent
An object that represents an event happening along the processing:
Field | Type | Description |
---|---|---|
eventType | String | Event type. |
payload | Map | Event payload. |
SNSMobileSDKAnswerType
An enum describing the possible answers:
Case | Description |
---|---|
Green | Positive answer. |
Red | Negative answer. |
Yellow | Neutral answer. |
Error | Something went wrong. |
Ignored | Check had not ever been started. |
Updated 5 days ago