Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class EIdReader(context: Context) {
if (allFaceImageInfos.isNotEmpty()) {
val faceImageInfo = allFaceImageInfos.iterator().next()
val image = bitmapUtil.getImage(faceImageInfo.imageInputStream, faceImageInfo.imageLength,faceImageInfo.mimeType)
nfcResult.originalFacePhoto = image
nfcResult.originalFacePhoto = image.base64
}
if (includeRawData) {
dataGroupData["DG2"] = Base64.encodeToString(dg2File.encoded, Base64.NO_WRAP)
Expand All @@ -135,6 +135,6 @@ class EIdReader(context: Context) {
val sodFile = sodIn.readBytes()
dataGroupData["SOD"] = Base64.encodeToString(sodFile, Base64.NO_WRAP)
}
return EIdReadResult("OK", nfcResult, dataGroupData)
return EIdReadResult("OK", null, nfcResult, dataGroupData)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.modules.core.DeviceEventManagerModule
import io.twentysixty.rn.eidreader.dto.MrzInfo
import io.twentysixty.rn.eidreader.dto.EIdReadResult
import io.twentysixty.rn.eidreader.utils.BitmapUtil
import io.twentysixty.rn.eidreader.utils.JsonToReactMap
import io.twentysixty.rn.eidreader.utils.serializeToMap
Expand Down Expand Up @@ -210,7 +211,14 @@ class EIdReaderModule(reactContext: ReactApplicationContext) :
_dialog?.setMessage(message)
})
stopReading(false)
_promise?.reject(e)
stopReading()

val result = EIdReadResult("Error", null, null)
result.errorMsg = e.message

val map = result.serializeToMap()
val reactMap = jsonToReactMap.convertJsonToMap(JSONObject(map))
_promise?.resolve(reactMap)
}

@ReactMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ data class EIdData(
var lastName: String? = null,
var mrz: String? = null,
var nationality: String? = null,
var originalFacePhoto: NfcImage? = null,
var originalFacePhoto: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.twentysixty.rn.eidreader.dto

data class EIdReadResult(
var status: String,
var errorMsg: String? = null,
var data: EIdData? = null,
var dataGroupsBase64: MutableMap<String, String>? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BitmapUtil(private val context: Context) {
val inputStream: InputStream = ByteArrayInputStream(buffer, 0, imageLength)
val bitmapImage = decodeImage(mimeType, inputStream)
image.bitmap = bitmapImage
val base64Image = Base64.encodeToString(buffer, Base64.DEFAULT)
val base64Image = Base64.encodeToString(buffer, Base64.NO_WRAP)
image.base64 = base64Image
return image
}
Expand Down
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type EidReadStatus = 'OK' | 'Error' | 'Canceled';

export type EIdReadResult = {
status: EidReadStatus;
errorMsg?: string;
data: {
birthDate?: string;
placeOfBirth?: string;
Expand Down
Loading