Skip to content

Commit

Permalink
Fix JSON bug on Flutter (#92)
Browse files Browse the repository at this point in the history
* fixed json formatting bug on Flutter

* update iOS to 10.2.3

* added missing ActionResult responses

* updated changelog and version bump

* normalize results on ios to match android

* Update Android SDK version to v10.2.3 (#93)

Co-authored-by: GitHub Actions <actions@github.com>

* fix missing ActionResult

* fix wrong json serialization on iOS

* fixed enhanced docV

* updated to iOS 10.2.4

* updated CHANGELOG.md

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Actions <actions@github.com>
  • Loading branch information
3 people authored Jul 23, 2024
1 parent 514ff6b commit c269b77
Show file tree
Hide file tree
Showing 17 changed files with 184 additions and 96 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release Notes

## 10.1.6

* Fixed badly formatted json responses
* Normalize the responses between android and iOS
* Fixed broken EnhancedDocV Flow on iOS
* Bump iOS to 10.2.4 (https://github.com/smileidentity/ios/releases/tag/v10.2.4)
* Bump Android to 10.2.3 (https://github.com/smileidentity/android/releases/tag/v10.2.3)

## 10.1.5

* Fix navigation issue on iOS Flutter app
Expand Down
3 changes: 3 additions & 0 deletions android/src/main/kotlin/com/smileidentity/flutter/Mapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ fun ActionResult.toResponse() =
ActionResult.NotVerified -> FlutterActionResult.NOTVERIFIED
ActionResult.NotDone -> FlutterActionResult.NOTDONE
ActionResult.IssuerUnavailable -> FlutterActionResult.ISSUERUNAVAILABLE
ActionResult.IdAuthorityPhotoNotAvailable ->
FlutterActionResult.IDAUTHORITYPHOTONOTAVAILABLE
ActionResult.SentToHumanReview -> FlutterActionResult.SENTTOHUMANREVIEW
ActionResult.Unknown -> FlutterActionResult.UNKNOWN
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ enum class FlutterActionResult(val raw: Int) {
NOTVERIFIED(12),
NOTDONE(13),
ISSUERUNAVAILABLE(14),
UNKNOWN(15);
IDAUTHORITYPHOTONOTAVAILABLE(15),
SENTTOHUMANREVIEW(16),
UNKNOWN(17);

companion object {
fun ofRaw(raw: Int): FlutterActionResult? {
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ PODS:
- integration_test (0.0.1):
- Flutter
- lottie-ios (4.4.3)
- smile_id (10.2.2):
- smile_id (10.2.4):
- Flutter
- SmileID (= 10.2.2)
- SmileID (10.2.2):
- SmileID (= 10.2.4)
- SmileID (10.2.4):
- lottie-ios (~> 4.4.2)
- Zip (~> 2.1.0)
- Zip (2.1.2)
Expand Down Expand Up @@ -34,8 +34,8 @@ SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
lottie-ios: fcb5e73e17ba4c983140b7d21095c834b3087418
smile_id: 6d62c54b3fcf0e2fb685c33b28c868477244ac54
SmileID: 9d95463475f933422b2ce136474813b528dbedb7
smile_id: 96b93395620895ce5a484e26960a2977c99602f3
SmileID: d36a5ed65e9c2ee44b5199bc97bb0f174834c326
Zip: b3fef584b147b6e582b2256a9815c897d60ddc67

PODFILE CHECKSUM: 929954fb8941cef06249e96bd1516fd2a22ed7a5
Expand Down
21 changes: 16 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:smile_id/smileid_messages.g.dart';
Expand Down Expand Up @@ -127,7 +128,9 @@ class MainContent extends StatelessWidget {
documentType: "DRIVERS_LICENSE",
onSuccess: (String? result) {
// Your success handling logic
final snackBar = SnackBar(content: Text("Success: $result"));
Map<String, dynamic> jsonResult = json.decode(result ?? '{}');
String formattedResult = jsonEncode(jsonResult);
final snackBar = SnackBar(content: Text("Success: $formattedResult"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Navigator.of(context).pop();
},
Expand Down Expand Up @@ -156,7 +159,9 @@ class MainContent extends StatelessWidget {
documentType: "DRIVERS_LICENSE",
onSuccess: (String? result) {
// Your success handling logic
final snackBar = SnackBar(content: Text("Success: $result"));
Map<String, dynamic> jsonResult = json.decode(result ?? '{}');
String formattedResult = jsonEncode(jsonResult);
final snackBar = SnackBar(content: Text("Success: $formattedResult"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Navigator.of(context).pop();
},
Expand All @@ -183,7 +188,9 @@ class MainContent extends StatelessWidget {
body: SmileIDSmartSelfieEnrollment(
onSuccess: (String? result) {
// Your success handling logic
final snackBar = SnackBar(content: Text("Success: $result"));
Map<String, dynamic> jsonResult = json.decode(result ?? '{}');
String formattedResult = jsonEncode(jsonResult);
final snackBar = SnackBar(content: Text("Success: $formattedResult"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Navigator.of(context).pop();
},
Expand All @@ -210,7 +217,9 @@ class MainContent extends StatelessWidget {
body: SmileIDSmartSelfieAuthentication(
onSuccess: (String? result) {
// Your success handling logic
final snackBar = SnackBar(content: Text("Success: $result"));
Map<String, dynamic> jsonResult = json.decode(result ?? '{}');
String formattedResult = jsonEncode(jsonResult);
final snackBar = SnackBar(content: Text("Success: $formattedResult"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Navigator.of(context).pop();
},
Expand Down Expand Up @@ -240,7 +249,9 @@ class MainContent extends StatelessWidget {
idNumber: "12345678",
onSuccess: (String? result) {
// Your success handling logic
final snackBar = SnackBar(content: Text("Success: $result"));
Map<String, dynamic> jsonResult = json.decode(result ?? '{}');
String formattedResult = jsonEncode(jsonResult);
final snackBar = SnackBar(content: Text("Success: $formattedResult"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Navigator.of(context).pop();
},
Expand Down
82 changes: 49 additions & 33 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "1.18.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -61,10 +61,10 @@ packages:
dependency: transitive
description:
name: file
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
version: "7.0.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -98,14 +98,30 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
leak_tracker:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "0.6.7"
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
lints:
dependency: transitive
description:
Expand All @@ -118,42 +134,42 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.12.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
platform:
dependency: transitive
description:
name: platform
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
version: "3.1.4"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -166,10 +182,10 @@ packages:
dependency: transitive
description:
name: process
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
url: "https://pub.dev"
source: hosted
version: "4.2.4"
version: "5.0.2"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -181,7 +197,7 @@ packages:
path: ".."
relative: true
source: path
version: "10.1.4"
version: "10.1.6"
source_span:
dependency: transitive
description:
Expand All @@ -194,18 +210,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
Expand Down Expand Up @@ -234,10 +250,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.7.0"
vector_math:
dependency: transitive
description:
Expand All @@ -250,18 +266,18 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f3743ca475e0c9ef71df4ba15eb2d7684eecd5c8ba20a462462e4e8b561b2e11
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "11.6.0"
version: "14.2.1"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
version: "3.0.3"
sdks:
dart: ">=3.0.5 <4.0.0"
flutter: ">=3.0.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
6 changes: 6 additions & 0 deletions ios/Classes/Mapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ extension ActionResult {
return .notDone
case .issuerUnavailable:
return .issuerUnavailable
case .idAuthorityPhotoNotAvailable:
return .idAuthorityPhotoNotAvailable
case .sentToHumanReview:
return .sentToHumanReview
case .unknown:
return .unknown
}
}
}
Expand Down
18 changes: 13 additions & 5 deletions ios/Classes/SmileIDBiometricKYC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,19 @@ class SmileIDBiometricKYC : NSObject, FlutterPlatformView, BiometricKycResultDel

func didSucceed(selfieImage: URL, livenessImages: [URL], didSubmitBiometricJob: Bool) {
_childViewController?.removeFromParent()
_channel.invokeMethod("onSuccess", arguments: """
{"selfieFile": "\(selfieImage.absoluteString)",
"livenessImages": \(livenessImages.map{ $0.absoluteString }),
"didSubmitBiometricJob": \(didSubmitBiometricJob),
""")
let arguments: [String: Any] = [
"selfieFile": selfieImage.absoluteString,
"livenessFiles": livenessImages.map { $0.absoluteString },
"didSubmitBiometricKycJob": didSubmitBiometricJob
]
do {
let jsonData = try JSONSerialization.data(withJSONObject: arguments, options: [])
if let jsonString = String(data: jsonData, encoding: .utf8) {
_channel.invokeMethod("onSuccess", arguments: jsonString)
}
} catch {
didError(error: error)
}
}

func didError(error: Error) {
Expand Down
20 changes: 14 additions & 6 deletions ios/Classes/SmileIDDocumentVerification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,20 @@ class SmileIDDocumentVerification : NSObject, FlutterPlatformView, DocumentVerif

func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitDocumentVerificationJob: Bool) {
_childViewController?.removeFromParent()
_channel.invokeMethod("onSuccess", arguments: """
{"selfieFile": "\(selfie.absoluteString)",
"documentFrontImage": \(documentFrontImage.absoluteString),
"documentBackImage": \(documentBackImage?.absoluteString ?? ""),
"didSubmitDocumentVerificationJob": \(didSubmitDocumentVerificationJob),
""")
let arguments: [String: Any] = [
"selfieFile": selfie.absoluteString,
"documentFrontFile": documentFrontImage.absoluteString,
"documentBackFile": documentBackImage?.absoluteString ?? "",
"didSubmitDocumentVerificationJob": didSubmitDocumentVerificationJob
]
do {
let jsonData = try JSONSerialization.data(withJSONObject: arguments, options: [])
if let jsonString = String(data: jsonData, encoding: .utf8) {
_channel.invokeMethod("onSuccess", arguments: jsonString)
}
} catch {
didError(error: error)
}
}

func didError(error: Error) {
Expand Down
Loading

0 comments on commit c269b77

Please sign in to comment.