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

Setting up Enhanced Biometric Screens #82

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SmileId_kotlinVersion=2.0.0
SmileId_minSdkVersion=21
SmileId_targetSdkVersion=34
SmileId_compileSdkVersion=34
SmileId_targetSdkVersion=35
SmileId_compileSdkVersion=35
SmileId_ndkversion=21.4.7075529
SmileId_androidVersion=10.3.7
SmileId_kotlinCompilerExtensionVersion=1.5.11
SmileId_androidVersion=10.4.0
#SmileId_kotlinCompilerExtensionVersion=1.5.11
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import com.smileidentity.react.viewmanagers.SmileIDDocumentCaptureViewManager
import com.smileidentity.react.viewmanagers.SmileIDDocumentVerificationViewManager
import com.smileidentity.react.viewmanagers.SmileIDEnhancedDocumentVerificationViewManager
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieAuthenticationViewManager
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieAuthenticationEnhancedViewManager
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieCaptureViewManager
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieEnrollmentViewManager
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieEnrollmentEnhancedViewManager
import com.smileidentity.react.views.SmileIDDocumentCaptureView

class SmileIdPackage : TurboReactPackage() {
Expand All @@ -24,6 +26,8 @@ class SmileIdPackage : TurboReactPackage() {
SmileIDDocumentCaptureViewManager(reactContext),
SmileIDSmartSelfieEnrollmentViewManager(reactContext),
SmileIDSmartSelfieAuthenticationViewManager(reactContext),
SmileIDSmartSelfieEnrollmentEnhancedViewManager(reactContext),
SmileIDSmartSelfieAuthenticationEnhancedViewManager(reactContext),
SmileIDDocumentVerificationViewManager(reactContext),
SmileIDEnhancedDocumentVerificationViewManager(reactContext),
SmileIDConsentViewManager(reactContext),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.smileidentity.react.viewmanagers

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.SimpleViewManager
import com.facebook.react.uimanager.ThemedReactContext
import com.smileidentity.react.utils.getBoolOrDefault
import com.smileidentity.react.utils.getImmutableMapOrDefault
import com.smileidentity.react.utils.getStringOrDefault
import com.smileidentity.react.views.SmileIDSmartSelfieAuthenticationEnhancedView

@ReactModule(name = SmileIDSmartSelfieAuthenticationEnhancedViewManager.NAME)
class SmileIDSmartSelfieAuthenticationEnhancedViewManager(
private val reactApplicationContext: ReactApplicationContext
) : SimpleViewManager<SmileIDSmartSelfieAuthenticationEnhancedView>() {

override fun getName(): String = NAME

override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
return mapOf(
"onSmileResult" to mapOf(
"phasedRegistrationNames" to mapOf(
"bubbled" to "onResult"
)
)
)
}

override fun getCommandsMap(): Map<String, Int> {
return mapOf("setParams" to COMMAND_SET_PARAMS)
}

override fun receiveCommand(
view: SmileIDSmartSelfieAuthenticationEnhancedView,
commandId: String?,
args: ReadableArray?
) {
super.receiveCommand(view, commandId, args)
when (commandId?.toInt()) {
COMMAND_SET_PARAMS -> {
// Extract params from args and apply to view
val params = args?.getMap(0)
params?.let {
view.extraPartnerParams = params.getImmutableMapOrDefault("extraPartnerParams")
view.userId = params.getStringOrDefault("userId")
view.showAttribution = params.getBoolOrDefault("showAttribution", true)
view.showInstructions = params.getBoolOrDefault("showInstructions", true)
view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false)
view.renderContent()
}
}
}
}

override fun createViewInstance(p0: ThemedReactContext): SmileIDSmartSelfieAuthenticationEnhancedView {
return SmileIDSmartSelfieAuthenticationEnhancedView(reactApplicationContext)
}

companion object {
const val NAME = "SmileIDSmartSelfieAuthenticationEnhancedView"
const val COMMAND_SET_PARAMS = 2
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.smileidentity.react.viewmanagers

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.SimpleViewManager
import com.facebook.react.uimanager.ThemedReactContext
import com.smileidentity.react.utils.getBoolOrDefault
import com.smileidentity.react.utils.getImmutableMapOrDefault
import com.smileidentity.react.utils.getStringOrDefault
import com.smileidentity.react.views.SmileIDSmartSelfieEnrollmentEnhancedView

@ReactModule(name = SmileIDSmartSelfieEnrollmentEnhancedViewManager.NAME)
class SmileIDSmartSelfieEnrollmentEnhancedViewManager(
private val reactApplicationContext: ReactApplicationContext
) : SimpleViewManager<SmileIDSmartSelfieEnrollmentEnhancedView>() {

override fun getName(): String = NAME

override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
return mapOf(
"onSmileResult" to mapOf(
"phasedRegistrationNames" to mapOf(
"bubbled" to "onResult"
)
)
)
}

override fun getCommandsMap(): Map<String, Int> {
return mapOf("setParams" to COMMAND_SET_PARAMS)
}

override fun receiveCommand(
view: SmileIDSmartSelfieEnrollmentEnhancedView,
commandId: String?,
args: ReadableArray?
) {
super.receiveCommand(view, commandId, args)
when (commandId?.toInt()) {
COMMAND_SET_PARAMS -> {
// Extract params from args and apply to view
val params = args?.getMap(0)
params?.let {
view.extraPartnerParams = params.getImmutableMapOrDefault("extraPartnerParams")
view.userId = params.getStringOrDefault("userId")
view.showAttribution = params.getBoolOrDefault("showAttribution", true)
view.showInstructions = params.getBoolOrDefault("showInstructions", true)
view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false)
view.renderContent()
}
}
}
}

override fun createViewInstance(p0: ThemedReactContext): SmileIDSmartSelfieEnrollmentEnhancedView {
return SmileIDSmartSelfieEnrollmentEnhancedView(reactApplicationContext)
}

companion object {
const val NAME = "SmileIDSmartSelfieEnrollmentEnhancedView"
const val COMMAND_SET_PARAMS = 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.smileidentity.react.views

import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
import com.facebook.react.bridge.ReactApplicationContext
import com.smileidentity.SmileID
import com.smileidentity.compose.SmartSelfieAuthenticationEnhanced
import com.smileidentity.react.results.SmartSelfieCaptureResult
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
import com.smileidentity.results.SmileIDResult
import com.smileidentity.util.randomUserId
import kotlinx.collections.immutable.toImmutableMap

class SmileIDSmartSelfieAuthenticationEnhancedView(context: ReactApplicationContext) :
SmileIDView(context) {

override fun renderContent() {
composeView.apply {
val customViewModelStoreOwner = CustomViewModelStoreOwner()
setContent {
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
SmileID.SmartSelfieAuthenticationEnhanced(
userId = userId ?: rememberSaveable { randomUserId() },
allowNewEnroll = allowNewEnroll ?: false,
showAttribution = showAttribution,
showInstructions = showInstructions,
extraPartnerParams = extraPartnerParams,
) { res ->
when (res) {
is SmileIDResult.Success -> {
// val result =
// SmartSelfieCaptureResult(
// selfieFile = res.data.selfieFile,
// livenessFiles = res.data.livenessFiles,
// apiResponse = res.data.apiResponse,
// )
// val newMoshi =
// SmileID.moshi
// .newBuilder()
// .add(SelfieCaptureResultAdapter.FACTORY)
// .build()
// val json =
// try {
// newMoshi
// .adapter(SmartSelfieCaptureResult::class.java)
// .toJson(result)
// } catch (e: Exception) {
// emitFailure(e)
// return@SmartSelfieAuthentication
// }
// json?.let { js ->
// emitSuccess(js)
// }
}

is SmileIDResult.Error -> emitFailure(res.throwable)
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.smileidentity.react.views

import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
import com.facebook.react.bridge.ReactApplicationContext
import com.smileidentity.SmileID
import com.smileidentity.compose.SmartSelfieEnrollmentEnhanced
import com.smileidentity.react.results.SmartSelfieCaptureResult
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
import com.smileidentity.results.SmileIDResult
import com.smileidentity.util.randomUserId
import kotlinx.collections.immutable.toImmutableMap

class SmileIDSmartSelfieEnrollmentEnhancedView(context: ReactApplicationContext) : SmileIDView(context) {

override fun renderContent() {
composeView.apply {
setContent {
val customViewModelStoreOwner = CustomViewModelStoreOwner()
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
SmileID.SmartSelfieEnrollmentEnhanced(
userId = userId ?: rememberSaveable { randomUserId() },
allowNewEnroll = allowNewEnroll ?: false,
showAttribution = showAttribution,
showInstructions = showInstructions,
extraPartnerParams = extraPartnerParams,
) { res ->
when (res) {
is SmileIDResult.Success -> {
// val result =
// SmartSelfieCaptureResult(
// selfieFile = res.data.selfieFile,
// livenessFiles = res.data.livenessFiles,
// apiResponse = res.data.apiResponse,
// )
// val newMoshi =
// SmileID.moshi
// .newBuilder()
// .add(SelfieCaptureResultAdapter.FACTORY)
// .build()
// val json =
// try {
// newMoshi
// .adapter(SmartSelfieCaptureResult::class.java)
// .toJson(result)
// } catch (e: Exception) {
// emitFailure(e)
// return@SmartSelfieEnrollment
// }
// json?.let { js ->
// emitSuccess(js)
// }
}

is SmileIDResult.Error -> emitFailure(res.throwable)
}
}
}
}
}
}
}
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ PODS:
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- SmileID (= 10.2.17)
- SmileID (= 10.3.2)
- Yoga
- React-nativeconfig (0.74.2)
- React-NativeModulesApple (0.74.2):
Expand Down Expand Up @@ -1216,7 +1216,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- SmileID (10.2.17):
- SmileID (10.3.2):
- FingerprintJS
- lottie-ios (~> 4.4.2)
- ZIPFoundation (~> 0.9)
Expand Down Expand Up @@ -1444,7 +1444,7 @@ SPEC CHECKSUMS:
React-logger: 29fa3e048f5f67fe396bc08af7606426d9bd7b5d
React-Mapbuffer: bf56147c9775491e53122a94c423ac201417e326
react-native-safe-area-context: 4532f1a0c5d34a46b9324ccaaedcb5582a302b7d
react-native-smile-id: 51ea0d04401552e49a59558ca6eb1b199cc3f16d
react-native-smile-id: 077bba4d98411f6d1af5b4ebaaa7d4f75bea8bf9
React-nativeconfig: 9f223cd321823afdecf59ed00861ab2d69ee0fc1
React-NativeModulesApple: ff7efaff7098639db5631236cfd91d60abff04c0
React-perflogger: 32ed45d9cee02cf6639acae34251590dccd30994
Expand All @@ -1469,11 +1469,11 @@ SPEC CHECKSUMS:
React-utils: 4476b7fcbbd95cfd002f3e778616155241d86e31
ReactCommon: ecad995f26e0d1e24061f60f4e5d74782f003f12
RNScreens: 48bc9eba07f93971071a5268b4fe5fcb784a5ef8
SmileID: 44fef36001a02aa7362368e8a3f1127c03751166
SmileID: 650b97c8786e4d79851b08bb5a12ae149ea78f38
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: ae3c32c514802d30f687a04a6a35b348506d411f
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c

PODFILE CHECKSUM: 92128f18619da6c6e525b6e782e26be40527bc29

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
Loading
Loading