Skip to content

Commit

Permalink
Update Flutter SDK (#17)
Browse files Browse the repository at this point in the history
* update flutter version with native sdks

* versions update

* updated iOS results

* updated ktlint version

* added setEnvironment and setCallbackUrl methods

* added setEnvironment and setCallbackUrl on Swift

* enable named parameters in flutter

* added CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: Vansh Gandhi <vansh@smileidentity.com>

---------

Co-authored-by: Vansh Gandhi <vansh@smileidentity.com>
  • Loading branch information
jumaallan and vanshg authored Oct 18, 2023
1 parent ffec039 commit 6aa6ce8
Showing 17 changed files with 194 additions and 78 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

# 10.0.0-beta03
- Allow setEnvironment({required bool useSandbox}) to enable sandbox or production environment
- Allow setCallbackUrl({required Uri callbackUrl}) to set a callback url for all submitted jobs.
- Bug Fixes and Improvements from iOS v10.0.0-beta10 and Android v10.0.0-beta09

# 10.0.0-beta02
- Support for Document Verification, exposed as a `SmileIDDocumentVerification` Widget
- Support for SmartSelfie Authentication, exposed as a `SmileIDSmartSelfieAuthentication` Widget
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group "com.smileidentity.flutter"
version findProperty("SDK_VERSION") ?: "10.0.0-beta08"
version findProperty("SDK_VERSION") ?: "10.0.0-beta09"

buildscript {
ext.kotlin_version = "1.9.10"
@@ -12,7 +12,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:8.1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.6.0"
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.6.1"
}
}

Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.net.URL

class SmileIDPlugin : FlutterPlugin, SmileIDApi, ActivityAware {

@@ -46,7 +47,15 @@ class SmileIDPlugin : FlutterPlugin, SmileIDApi, ActivityAware {
}

override fun initialize() {
SmileID.initialize(appContext, enableCrashReporting = false)
SmileID.initialize(context = appContext, enableCrashReporting = false)
}

override fun setEnvironment(useSandbox: Boolean) {
SmileID.setEnvironment(useSandbox = useSandbox)
}

override fun setCallbackUrl(callbackUrl: String) {
SmileID.setCallbackUrl(callbackUrl = URL(callbackUrl))
}

override fun authenticate(
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Autogenerated from Pigeon (v10.1.6), do not edit directly.
// See also: https://pub.dev/packages/pigeon


import android.util.Log
import io.flutter.plugin.common.BasicMessageChannel
import io.flutter.plugin.common.BinaryMessenger
@@ -18,13 +19,13 @@ private fun wrapError(exception: Throwable): List<Any?> {
return listOf(
exception.code,
exception.message,
exception.details,
exception.details
)
} else {
return listOf(
exception.javaClass.simpleName,
exception.toString(),
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception),
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)
)
}
}
@@ -35,16 +36,15 @@ private fun wrapError(exception: Throwable): List<Any?> {
* @property message The error message.
* @property details The error details. Must be a datatype supported by the api codec.
*/
class FlutterError(
class FlutterError (
val code: String,
override val message: String? = null,
val details: Any? = null,
val details: Any? = null
) : Throwable()

enum class FlutterJobType(val raw: Int) {
ENHANCEDKYC(0),
DOCUMENTVERIFICATION(1),
;
DOCUMENTVERIFICATION(1);

companion object {
fun ofRaw(raw: Int): FlutterJobType? {
@@ -58,11 +58,11 @@ enum class FlutterJobType(val raw: Int) {
*
* Generated class from Pigeon that represents data sent in messages.
*/
data class FlutterPartnerParams(
data class FlutterPartnerParams (
val jobType: FlutterJobType? = null,
val jobId: String,
val userId: String,
val extras: Map<String?, String?>? = null,
val extras: Map<String?, String?>? = null

) {
companion object {
@@ -108,13 +108,13 @@ data class FlutterPartnerParams(
*
* Generated class from Pigeon that represents data sent in messages.
*/
data class FlutterAuthenticationRequest(
data class FlutterAuthenticationRequest (
val jobType: FlutterJobType,
val country: String? = null,
val idType: String? = null,
val updateEnrolledImage: Boolean? = null,
val jobId: String? = null,
val userId: String? = null,
val userId: String? = null

) {
companion object {
@@ -126,14 +126,7 @@ data class FlutterAuthenticationRequest(
val updateEnrolledImage = list[3] as Boolean?
val jobId = list[4] as String?
val userId = list[5] as String?
return FlutterAuthenticationRequest(
jobType,
country,
idType,
updateEnrolledImage,
jobId,
userId,
)
return FlutterAuthenticationRequest(jobType, country, idType, updateEnrolledImage, jobId, userId)
}
}
fun toList(): List<Any?> {
@@ -158,13 +151,13 @@ data class FlutterAuthenticationRequest(
*
* Generated class from Pigeon that represents data sent in messages.
*/
data class FlutterAuthenticationResponse(
data class FlutterAuthenticationResponse (
val success: Boolean,
val signature: String,
val timestamp: String,
val partnerParams: FlutterPartnerParams,
val callbackUrl: String? = null,
val consentInfo: FlutterConsentInfo? = null,
val consentInfo: FlutterConsentInfo? = null

) {
companion object {
@@ -178,14 +171,7 @@ data class FlutterAuthenticationResponse(
val consentInfo: FlutterConsentInfo? = (list[5] as List<Any?>?)?.let {
FlutterConsentInfo.fromList(it)
}
return FlutterAuthenticationResponse(
success,
signature,
timestamp,
partnerParams,
callbackUrl,
consentInfo,
)
return FlutterAuthenticationResponse(success, signature, timestamp, partnerParams, callbackUrl, consentInfo)
}
}
fun toList(): List<Any?> {
@@ -206,9 +192,9 @@ data class FlutterAuthenticationResponse(
*
* Generated class from Pigeon that represents data sent in messages.
*/
data class FlutterConsentInfo(
data class FlutterConsentInfo (
val canAccess: Boolean,
val consentRequired: Boolean,
val consentRequired: Boolean

) {
companion object {
@@ -233,7 +219,7 @@ data class FlutterConsentInfo(
*
* Generated class from Pigeon that represents data sent in messages.
*/
data class FlutterEnhancedKycRequest(
data class FlutterEnhancedKycRequest (
val country: String,
val idType: String,
val idNumber: String,
@@ -246,7 +232,7 @@ data class FlutterEnhancedKycRequest(
val callbackUrl: String? = null,
val partnerParams: FlutterPartnerParams,
val timestamp: String,
val signature: String,
val signature: String

) {
companion object {
@@ -288,8 +274,8 @@ data class FlutterEnhancedKycRequest(
}

/** Generated class from Pigeon that represents data sent in messages. */
data class FlutterEnhancedKycAsyncResponse(
val success: Boolean,
data class FlutterEnhancedKycAsyncResponse (
val success: Boolean

) {
companion object {
@@ -343,7 +329,7 @@ private object SmileIDApiCodec : StandardMessageCodec() {
else -> super.readValueOfType(type, buffer)
}
}
override fun writeValue(stream: ByteArrayOutputStream, value: Any?) {
override fun writeValue(stream: ByteArrayOutputStream, value: Any?) {
when (value) {
is FlutterAuthenticationRequest -> {
stream.write(128)
@@ -377,30 +363,21 @@ private object SmileIDApiCodec : StandardMessageCodec() {
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
interface SmileIDApi {
fun initialize()
fun authenticate(
request: FlutterAuthenticationRequest,
callback: (Result<FlutterAuthenticationResponse>) -> Unit,
)
fun doEnhancedKycAsync(
request: FlutterEnhancedKycRequest,
callback: (Result<FlutterEnhancedKycAsyncResponse>) -> Unit,
)
fun setEnvironment(useSandbox: Boolean)
fun setCallbackUrl(callbackUrl: String)
fun authenticate(request: FlutterAuthenticationRequest, callback: (Result<FlutterAuthenticationResponse>) -> Unit)
fun doEnhancedKycAsync(request: FlutterEnhancedKycRequest, callback: (Result<FlutterEnhancedKycAsyncResponse>) -> Unit)

companion object {
/** The codec used by SmileIDApi. */
val codec: MessageCodec<Any?> by lazy {
SmileIDApiCodec
}

/** Sets up an instance of `SmileIDApi` to handle messages through the `binaryMessenger`. */
@Suppress("UNCHECKED_CAST")
fun setUp(binaryMessenger: BinaryMessenger, api: SmileIDApi?) {
run {
val channel = BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.smileid.SmileIDApi.initialize",
codec,
)
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.smileid.SmileIDApi.initialize", codec)
if (api != null) {
channel.setMessageHandler { _, reply ->
var wrapped: List<Any?>
@@ -417,11 +394,45 @@ interface SmileIDApi {
}
}
run {
val channel = BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.smileid.SmileIDApi.authenticate",
codec,
)
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.smileid.SmileIDApi.setEnvironment", codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val useSandboxArg = args[0] as Boolean
var wrapped: List<Any?>
try {
api.setEnvironment(useSandboxArg)
wrapped = listOf<Any?>(null)
} catch (exception: Throwable) {
wrapped = wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.smileid.SmileIDApi.setCallbackUrl", codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val callbackUrlArg = args[0] as String
var wrapped: List<Any?>
try {
api.setCallbackUrl(callbackUrlArg)
wrapped = listOf<Any?>(null)
} catch (exception: Throwable) {
wrapped = wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.smileid.SmileIDApi.authenticate", codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
@@ -441,16 +452,11 @@ interface SmileIDApi {
}
}
run {
val channel = BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.smileid.SmileIDApi.doEnhancedKycAsync",
codec,
)
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.smileid.SmileIDApi.doEnhancedKycAsync", codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val requestArg = args[0] as FlutterEnhancedKycRequest

api.doEnhancedKycAsync(requestArg) { result: Result<FlutterEnhancedKycAsyncResponse> ->
val error = result.exceptionOrNull()
if (error != null) {
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:8.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.6.0"
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.6.1"
}
}

12 changes: 6 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ PODS:
- Flutter (1.0.0)
- integration_test (0.0.1):
- Flutter
- smile_id (10.0.0-beta09):
- smile_id (10.0.0-beta10):
- Flutter
- SmileID (= 10.0.0-beta09)
- SmileID (10.0.0-beta09):
- SmileID (= 10.0.0-beta10)
- SmileID (10.0.0-beta10):
- Zip (~> 2.1.0)
- Zip (2.1.2)

@@ -30,10 +30,10 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
integration_test: 13825b8a9334a850581300559b8839134b124670
smile_id: 280d6479aab2ee1196acfd59d5349cfb216f04ac
SmileID: b1ce730e8596defe821fbd510b8e4f714885284d
smile_id: 963615dc5c256ef40338c09034dd0024747b0d60
SmileID: 5975f6130f357bfa08e9b1f731f9ce3e2d91c216
Zip: b3fef584b147b6e582b2256a9815c897d60ddc67

PODFILE CHECKSUM: 929954fb8941cef06249e96bd1516fd2a22ed7a5

COCOAPODS: 1.13.0
COCOAPODS: 1.12.1
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -181,7 +181,7 @@ packages:
path: ".."
relative: true
source: path
version: "10.0.0-beta01"
version: "10.0.0-beta03"
source_span:
dependency: transitive
description:
Loading

0 comments on commit 6aa6ce8

Please sign in to comment.