Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration from platform views 🚧 #136

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5b0e16f
rough poc of platform views migration
CoderNamedHendrick Jan 5, 2025
44e4851
remove unncessary delegate controller
CoderNamedHendrick Jan 5, 2025
148ae75
resolve comments
CoderNamedHendrick Jan 8, 2025
b4c50e6
upgrade pigeon, get codegen improvements
CoderNamedHendrick Jan 8, 2025
cbaa035
Merge branch 'main' into feature/migration-from-platform-views
jumaallan Jan 8, 2025
1f14209
updated configurations
jumaallan Jan 8, 2025
947b04e
code formatting and linting
jumaallan Jan 8, 2025
484112f
- remove title bar
CoderNamedHendrick Jan 8, 2025
98e5446
- added smartSelfieEnrollment to SmileID class returning SmileIDSdkRe…
CoderNamedHendrick Jan 8, 2025
13abc1a
remove unnecessary format
CoderNamedHendrick Jan 8, 2025
f3a270d
remove unused didSubmitBiometricKycJob parameter
CoderNamedHendrick Jan 8, 2025
d861168
- added smile_id_smart_selfie_authentication method
CoderNamedHendrick Jan 13, 2025
f1624d4
refactor products api to separate implementation
CoderNamedHendrick Jan 13, 2025
97f3465
remove xcode file creation comments
CoderNamedHendrick Jan 13, 2025
81a157b
remove need for client to wrap application in a UINavigationController
CoderNamedHendrick Jan 14, 2025
b489320
fix linting issues flutter
CoderNamedHendrick Jan 14, 2025
dc7a369
resolve linting issues on android
CoderNamedHendrick Jan 14, 2025
617d3bd
- attend to issues with PR
CoderNamedHendrick Jan 21, 2025
4fddd84
remove portrait hosting controller attempt at locking iOS to portrait…
CoderNamedHendrick Jan 21, 2025
14c6800
Merge branch 'main' into feature/migration-from-platform-views
jumaallan Jan 23, 2025
47f5986
fix force light mode on ios
CoderNamedHendrick Jan 25, 2025
723bb6f
add back button
CoderNamedHendrick Jan 25, 2025
964664d
- added document verification product
CoderNamedHendrick Jan 29, 2025
2529d64
- added selfie capture product
CoderNamedHendrick Feb 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
channel: 'stable'
- name: Install Dependencies
run: flutter pub get && cd example && flutter pub get && cd ..

- name: Lint Flutter
run: flutter analyze
Android:
Expand Down
5 changes: 3 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ android {
dependencies {
implementation "com.smileidentity:android-sdk:${smileVersion}"
implementation "androidx.core:core-ktx"
implementation "androidx.activity:activity-compose:1.9.3"
implementation "androidx.compose.ui:ui"
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose'
implementation "androidx.compose.material3:material3"
Expand All @@ -96,7 +97,7 @@ android {
implementation "com.google.mlkit:object-detection:17.0.2"

testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation "io.mockk:mockk:1.13.13"
testImplementation "io.mockk:mockk:1.13.14"
}
}

Expand All @@ -105,4 +106,4 @@ ktlint {
filter {
exclude { it.file.path.contains(".g.kt") }
}
}
}
62 changes: 61 additions & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
<manifest />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<application android:theme="@android:style/Theme.Light.NoTitleBar">
<activity
android:name=".SmileIDSmartSelfieEnrollmentActivity"
CoderNamedHendrick marked this conversation as resolved.
Show resolved Hide resolved
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="DiscouragedApi" />
<activity
android:name=".SmileIDSmartSelfieAuthenticationActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="DiscouragedApi" />

<activity
android:name=".enhanced.SmileIDSmartSelfieEnrollmentEnhancedActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="DiscouragedApi" />

<activity
android:name=".enhanced.SmileIDSmartSelfieAuthenticationEnhancedActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="DiscouragedApi" />

<activity
android:name=".SmileIDDocumentVerificationActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="DiscouragedApi" />

<activity
android:name=".SmileIDBiometricKYCActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="DiscouragedApi" />

<activity
android:name=".SmileIDEnhancedDocumentVerificationActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="DiscouragedApi" />

<activity
android:name=".SmileIDSelfieCaptureActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="DiscouragedApi" />

<activity
android:name=".SmileIDDocumentCaptureActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:ignore="DiscouragedApi" />

</application>

</manifest>
99 changes: 65 additions & 34 deletions android/src/main/kotlin/com/smileidentity/flutter/Mapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import FlutterUploadImageInfo
import FlutterUploadRequest
import FlutterValidDocument
import FlutterValidDocumentsResponse
import android.os.Bundle
import com.smileidentity.models.ActionResult
import com.smileidentity.models.Actions
import com.smileidentity.models.Antifraud
Expand Down Expand Up @@ -115,35 +116,35 @@ fun convertNonNullMapToNullable(map: Map<String, String>): Map<String?, String?>

fun FlutterJobType.toRequest() =
when (this) {
FlutterJobType.ENHANCEDKYC -> JobType.EnhancedKyc
FlutterJobType.DOCUMENTVERIFICATION -> JobType.DocumentVerification
FlutterJobType.BIOMETRICKYC -> JobType.BiometricKyc
FlutterJobType.ENHANCEDDOCUMENTVERIFICATION -> JobType.EnhancedDocumentVerification
FlutterJobType.SMARTSELFIEENROLLMENT -> JobType.SmartSelfieEnrollment
FlutterJobType.SMARTSELFIEAUTHENTICATION -> JobType.SmartSelfieAuthentication
FlutterJobType.ENHANCED_KYC -> JobType.EnhancedKyc
FlutterJobType.DOCUMENT_VERIFICATION -> JobType.DocumentVerification
FlutterJobType.BIOMETRIC_KYC -> JobType.BiometricKyc
FlutterJobType.ENHANCED_DOCUMENT_VERIFICATION -> JobType.EnhancedDocumentVerification
FlutterJobType.SMART_SELFIE_ENROLLMENT -> JobType.SmartSelfieEnrollment
FlutterJobType.SMART_SELFIE_AUTHENTICATION -> JobType.SmartSelfieAuthentication
}

fun JobType.toResponse() =
when (this) {
JobType.EnhancedKyc -> FlutterJobType.ENHANCEDKYC
JobType.DocumentVerification -> FlutterJobType.DOCUMENTVERIFICATION
JobType.BiometricKyc -> FlutterJobType.BIOMETRICKYC
JobType.EnhancedDocumentVerification -> FlutterJobType.ENHANCEDDOCUMENTVERIFICATION
JobType.SmartSelfieEnrollment -> FlutterJobType.SMARTSELFIEENROLLMENT
JobType.SmartSelfieAuthentication -> FlutterJobType.SMARTSELFIEAUTHENTICATION
JobType.EnhancedKyc -> FlutterJobType.ENHANCED_KYC
JobType.DocumentVerification -> FlutterJobType.DOCUMENT_VERIFICATION
JobType.BiometricKyc -> FlutterJobType.BIOMETRIC_KYC
JobType.EnhancedDocumentVerification -> FlutterJobType.ENHANCED_DOCUMENT_VERIFICATION
JobType.SmartSelfieEnrollment -> FlutterJobType.SMART_SELFIE_ENROLLMENT
JobType.SmartSelfieAuthentication -> FlutterJobType.SMART_SELFIE_AUTHENTICATION
else -> TODO("Not yet implemented")
}

fun FlutterJobTypeV2.toRequest() =
when (this) {
FlutterJobTypeV2.SMARTSELFIEAUTHENTICATION -> JobTypeV2.SmartSelfieAuthentication
FlutterJobTypeV2.SMARTSELFIEENROLLMENT -> JobTypeV2.SmartSelfieEnrollment
FlutterJobTypeV2.SMART_SELFIE_AUTHENTICATION -> JobTypeV2.SmartSelfieAuthentication
FlutterJobTypeV2.SMART_SELFIE_ENROLLMENT -> JobTypeV2.SmartSelfieEnrollment
}

fun JobTypeV2.toResponse() =
when (this) {
JobTypeV2.SmartSelfieAuthentication -> FlutterJobTypeV2.SMARTSELFIEAUTHENTICATION
JobTypeV2.SmartSelfieEnrollment -> FlutterJobTypeV2.SMARTSELFIEENROLLMENT
JobTypeV2.SmartSelfieAuthentication -> FlutterJobTypeV2.SMART_SELFIE_AUTHENTICATION
JobTypeV2.SmartSelfieEnrollment -> FlutterJobTypeV2.SMART_SELFIE_ENROLLMENT
else -> TODO("Not yet implemented")
}

Expand Down Expand Up @@ -222,14 +223,14 @@ fun FlutterUploadImageInfo.toRequest() =

fun FlutterImageType.toRequest() =
when (this) {
FlutterImageType.SELFIEJPGFILE -> ImageType.SelfieJpgFile
FlutterImageType.IDCARDJPGFILE -> ImageType.IdCardJpgFile
FlutterImageType.SELFIEJPGBASE64 -> ImageType.SelfieJpgBase64
FlutterImageType.IDCARDJPGBASE64 -> ImageType.IdCardJpgBase64
FlutterImageType.LIVENESSJPGFILE -> ImageType.LivenessJpgFile
FlutterImageType.IDCARDREARJPGFILE -> ImageType.IdCardRearJpgFile
FlutterImageType.LIVENESSJPGBASE64 -> ImageType.LivenessJpgBase64
FlutterImageType.IDCARDREARJPGBASE64 -> ImageType.IdCardRearJpgBase64
FlutterImageType.SELFIE_JPG_FILE -> ImageType.SelfieJpgFile
FlutterImageType.ID_CARD_JPG_FILE -> ImageType.IdCardJpgFile
FlutterImageType.SELFIE_JPG_BASE64 -> ImageType.SelfieJpgBase64
FlutterImageType.ID_CARD_JPG_BASE64 -> ImageType.IdCardJpgBase64
FlutterImageType.LIVENESS_JPG_FILE -> ImageType.LivenessJpgFile
FlutterImageType.ID_CARD_REAR_JPG_FILE -> ImageType.IdCardRearJpgFile
FlutterImageType.LIVENESS_JPG_BASE64 -> ImageType.LivenessJpgBase64
FlutterImageType.ID_CARD_REAR_JPG_BASE64 -> ImageType.IdCardRearJpgBase64
}

fun FlutterIdInfo.toRequest() =
Expand Down Expand Up @@ -311,20 +312,21 @@ fun ActionResult.toResponse() =
ActionResult.Completed -> FlutterActionResult.COMPLETED
ActionResult.Approved -> FlutterActionResult.APPROVED
ActionResult.Verified -> FlutterActionResult.VERIFIED
ActionResult.ProvisionallyApproved -> FlutterActionResult.PROVISIONALLYAPPROVED
ActionResult.ProvisionallyApproved -> FlutterActionResult.PROVISIONALLY_APPROVED
ActionResult.Returned -> FlutterActionResult.RETURNED
ActionResult.NotReturned -> FlutterActionResult.NOTRETURNED
ActionResult.NotReturned -> FlutterActionResult.NOT_RETURNED
ActionResult.Failed -> FlutterActionResult.FAILED
ActionResult.Rejected -> FlutterActionResult.REJECTED
ActionResult.UnderReview -> FlutterActionResult.UNDERREVIEW
ActionResult.UnableToDetermine -> FlutterActionResult.UNABLETODETERMINE
ActionResult.NotApplicable -> FlutterActionResult.NOTAPPLICABLE
ActionResult.NotVerified -> FlutterActionResult.NOTVERIFIED
ActionResult.NotDone -> FlutterActionResult.NOTDONE
ActionResult.IssuerUnavailable -> FlutterActionResult.ISSUERUNAVAILABLE
ActionResult.UnderReview -> FlutterActionResult.UNDER_REVIEW
ActionResult.UnableToDetermine -> FlutterActionResult.UNABLE_TO_DETERMINE
ActionResult.NotApplicable -> FlutterActionResult.NOT_APPLICABLE
ActionResult.NotVerified -> FlutterActionResult.NOT_VERIFIED
ActionResult.NotDone -> FlutterActionResult.NOT_DONE
ActionResult.IssuerUnavailable -> FlutterActionResult.ISSUER_UNAVAILABLE
ActionResult.IdAuthorityPhotoNotAvailable ->
FlutterActionResult.IDAUTHORITYPHOTONOTAVAILABLE
ActionResult.SentToHumanReview -> FlutterActionResult.SENTTOHUMANREVIEW
FlutterActionResult.ID_AUTHORITY_PHOTO_NOT_AVAILABLE

ActionResult.SentToHumanReview -> FlutterActionResult.SENT_TO_HUMAN_REVIEW
ActionResult.Unknown -> FlutterActionResult.UNKNOWN
}

Expand Down Expand Up @@ -623,3 +625,32 @@ fun FlutterConfig.toRequest() =
prodBaseUrl = prodBaseUrl,
sandboxBaseUrl = sandboxBaseUrl,
)

fun SmartSelfieResponse.buildBundle() =
Bundle().apply {
this.putString("code", code)
this.putString("created_at", createdAt)
this.putString("job_id", jobId)
this.putString("job_type", jobType.name)
this.putString("message", message)
this.putString("partner_id", partnerId)
this.putBundle(
"partner_params",
Bundle().apply {
partnerParams.forEach {
putString(it.key, it.value)
}
},
)
this.putString("status", status.name)
this.putString("updated_at", updatedAt)
this.putString("user_id", userId)
}

fun List<File>.pathList(): ArrayList<String> =
ArrayList<String>().let {
this.forEach { item ->
it.add(item.absolutePath)
}
return it
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.smileidentity.flutter

import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.smileidentity.SmileID
import com.smileidentity.compose.BiometricKYC
import com.smileidentity.models.IdInfo
import com.smileidentity.results.SmileIDResult
import com.smileidentity.util.randomJobId
import com.smileidentity.util.randomUserId
import kotlinx.collections.immutable.toImmutableMap

class SmileIDBiometricKYCActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val country = intent.getStringExtra("country") ?: ""
val idType = intent.getStringExtra("idType")
val idNumber = intent.getStringExtra("idNumber")
val firstName = intent.getStringExtra("firstName")
val middleName = intent.getStringExtra("middleName")
val lastName = intent.getStringExtra("lastName")
val dob = intent.getStringExtra("dob")
val bankCode = intent.getStringExtra("bankCode")
val entered =
if (intent.hasExtra("entered")) intent.getBooleanExtra("entered", false) else null
val userId = intent.getStringExtra("userId") ?: randomUserId()
val jobId = intent.getStringExtra("jobId") ?: randomJobId()
val allowNewEnroll = intent.getBooleanExtra("allowNewEnroll", false)
val allowAgentMode = intent.getBooleanExtra("allowAgentMode", false)
val showAttribution = intent.getBooleanExtra("showAttribution", true)
val showInstructions = intent.getBooleanExtra("showInstructions", true)
val extraPartnerParamsBundle = intent.getBundleExtra("extraPartnerParams")
val extraPartnerParams =
extraPartnerParamsBundle?.keySet()?.associateWith {
extraPartnerParamsBundle.getString(it)
} as? Map<String, String> ?: emptyMap()

setContent {
SmileID.BiometricKYC(
idInfo = IdInfo(
country = country,
idType = idType,
idNumber = idNumber,
firstName = firstName,
middleName = middleName,
lastName = lastName,
dob = dob,
bankCode = bankCode,
entered = entered,
),
userId = userId,
jobId = jobId,
allowNewEnroll = allowNewEnroll,
allowAgentMode = allowAgentMode,
showAttribution = showAttribution,
showInstructions = showInstructions,
extraPartnerParams = extraPartnerParams.toImmutableMap(),
) {
val intent = Intent()
when (it) {

is SmileIDResult.Success -> {
intent.putExtra("selfieFile", it.data.selfieFile.absolutePath)
intent.putStringArrayListExtra(
"livenessFiles",
it.data.livenessFiles.pathList(),
)
intent.putExtra(
"didSubmitBiometricKycJob",
it.data.didSubmitBiometricKycJob,
)

setResult(RESULT_OK, intent)
finish()
}

is SmileIDResult.Error -> {
intent.putExtra("error", it.throwable.message)
setResult(RESULT_CANCELED, intent)
finish()
}
}
}
}
}

companion object {
const val REQUEST_CODE = 16
}
}
Loading