Flutter
Latest GlobalPass Android SDK version: 1.2.18
1. Connect GlobalPass SDK
a. Add this code to the Project level build.gradle file under allprojects -> repositories
section:
/* GlobalPass SDK Maven Repository */
maven {
url 'https://pkgs.dev.azure.com/isun-ag/GlobalPassApp-Public/_packaging/GlobalPassAndroidSDK/maven/v1'
}
/* FaceTec SDK Maven Private Repository */
maven {
url 'https://pkgs.dev.azure.com/isun-ag/GlobalPassApp/_packaging/facetecandroid/maven/v1'
name 'facetecandroid'
credentials {
username "isun-ag"
password "<token>"
}
}
To get a <token> value used above, please contact GlobalPass support.
b. Add this code to the App level build.gradle file under dependencies
:
implementation 'ch.globalpass.sdk:release:1.2.18'
c. Sync gradle
If you use ProGuard in your project you should include these rules:
-keep class ch.globalpass.globalpasssdk.domain.model.** { *;}
-keep class ch.globalpass.globalpasssdk.data.networkmodels.** {*;}
-keep class org.jmrtd.** {*;}
-keep class net.sf.scuba.** {*;}
-keep class org.bouncycastle.** {*;}
-keep class org.spongycastle.** {*;}
-keep class org.ejbca.** {*;}
-dontwarn javax.annotation.Nullable
-dontwarn com.facetec.sdk.**
-keep class com.facetec.sdk.**
{ *; }
2. Android
class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(
flutterEngine.dartExecutor.binaryMessenger ,
"global_pass_plugin/kyc_channel"
).setMethodCallHandler{call , result->
val args = call.arguments as? Map<*,*>
val token : String = args?.get("token") as? String ?: " "
val isDev : Boolean = args?.get("isDev") as? Boolean ?: true
when (call.method) {
"startKyc" -> {
GlobalPassSDK.create(this).start(
token = token,
activity = MainActivity::class.java,
environment = if (isDev) GlobalPassEnvironment.Dev
else GlobalPassEnvironment.Prod,
)
result.success(true)
}
else -> {
result.notImplemented()
}
}
when (call.method) {
"startBiometrics" -> {
GlobalPassSDK.create(this).start(
token = token,
activity = MainActivity::class.java,
environment = if (isDev) GlobalPassEnvironment.Dev
else GlobalPassEnvironment.Prod,
flow = GlobalPassFlow.InstantBiometrics
)
result.success(true)
}
else -> {
result.notImplemented()
}
}
}
}
}
3. Flutter
abstract class KycPlatformInterface {
KycPlatformInterface();
static const MethodChannelmethodChannel=
MethodChannel('global_pass_plugin/kyc_channel');
MethodChannel get channel =>methodChannel;
Future<void> startKyc({
required String token,
required bool isDev,
}) {
throw UnimplementedError('startKyc() has not been implemented.');
}
Future<void> startBiometrics({
required String token,
required bool isDev,
}) {
throw UnimplementedError('startBiometrics() has not been implemented.');
}
}
class KycPlatformImpl extends KycPlatformInterface {
Future<void> startKyc({
required String token,
required bool isDev,
}) async {
await channel.invokeMethod<bool>(
'startKyc',
<String, dynamic>{
'token': token,
'isDev': isDev,
},
);
}
Future<void> startBiometrics({
required String token,
required bool isDev,
}) async {
await channel.invokeMethod<bool>(
'startBiometrics',
<String, dynamic>{
'token': token,
'isDev': isDev,
},
);
}
}
4. Start KYC or Instant Biometrics flow:
case States.readyToKYC:
switch (isDevEnvironment) {
case true:
appLocator
.get<KycPlatformInterface>()
.startKyc(
token: screeningToken ?? '',
isDev: isDevEnvironment,
)
.then((
response,
) {
resetAll();
}).catchError((error) {});
break;
case false:
appLocator
.get<KycPlatformInterface>()
.startKyc(
token: screeningToken ?? '',
isDev: !isDevEnvironment,
)
.then((response) {
resetAll();
}).catchError((error) {});
break;
}
break;
case States.readyToIB:
switch (isDevEnvironment) {
case true:
appLocator
.get<KycPlatformInterface>()
.startBiometrics(
token: biometricsId ?? '',
isDev: isDevEnvironment,
)
.then((response) {
resetAll();
}).catchError((error) {});
break;
case false:
appLocator
.get<KycPlatformInterface>()
.startBiometrics(
token: biometricsId ?? '',
isDev: !isDevEnvironment,
)
.then((response) {
resetAll();
}).catchError((error) {});
break;
}
break;
}
5. Additional optional parameters in start()
function:
There are additional optional parameters in start()
function:
Parameter | Description |
---|---|
enableFileLogger | Enable Logger to write SDK logs. |
widgetMode | Select matching widget mode if Split flow is used. |
externalId | Specify your internal customer identifier to be set on the screening. |
languageCode | Specify SDK language using available langauage options. |
globalPassSdk.start(
// ...
enableFileLogger = true,
widgetMode: WidgetMode = WidgetMode.FULL_MODE,
externalId: String? = null,
languageCode: String = "en"
)
enableFileLogger
There is an optional Logger that writes logs into file which could be found in Internal Storage:
File Storage → Android → data → “your app package” → files → logs → logs file
It is optional and false
by default. To enable the logger you need to set it to true
.
widgetMode
To use Split flow, matching widgetMode must be selected. By default it is set to FULL_MODE
. To select mode you can use sealed class WidgetMode
enum class WidgetMode(val value: String?) {
SPLIT_IDENTITY_MODE(value = "Identity"),
SPLIT_ADDRESS_MODE(value = "Address"),
FULL_MODE(value = null)
}
externalId
You can provide your own customer ID to be assigned to the screening flow. By default value is null
.
languageCode
By default, the SDK is displayed in English. To specify a different SDK display language, you can provide the locale code here.
Available locales:
en
- Englishde
- Germanes-MX
- Spanishit
- Italianlt
- Lithuanianpt-BR
- Portugueseru
- Russianar
- Arabiczh-CN
- Chinese Simplified
If an unsupported locale will be provided, the SDK will fallback to English.