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

Faltal exception NSInvalidArgumentException #213

Open
aarango opened this issue May 26, 2023 · 3 comments
Open

Faltal exception NSInvalidArgumentException #213

aarango opened this issue May 26, 2023 · 3 comments

Comments

@aarango
Copy link

aarango commented May 26, 2023

I have this error when a try use the IdBarcodeRecognizer

const uiSettings = new BlinkIDReactNative.BlinkIdOverlaySettings()
  uiSettings.firstSideInstructionsText = title
  const idBarcodeRecognizer = new BlinkIDReactNative.IdBarcodeRecognizer()
  const scanningResults = await BlinkIDReactNative.BlinkID.scanWithCamera(
    uiSettings,
    new BlinkIDReactNative.RecognizerCollection([idBarcodeRecognizer]),
    licenseKey,
  )

NSInvalidArgumentException: -[MBDate originalDateStringResult]: unrecognized selector sent to instance 0x282abe850
0 CoreFoundation 0x000000018f3cada0 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 40352
1 libobjc.A.dylib 0x00000001884883d0 objc_exception_throw + 60
2 CoreFoundation 0x000000018f53fb14 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 1567508
3 CoreFoundation 0x000000018f3e11c8 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 131528
4 CoreFoundation 0x000000018f4479f0 _CF_forwarding_prep_0 + 96
5 Trakku 0x0000000105657dd8 +[MBSerializationUtils serializeMBDateResult:] + 212
6 Trakku 0x00000001056547e0 -[MBIdBarcodeRecognizer(JsonSerialization) serializeResult] + 684
7 Trakku 0x000000010564a648 -[MBBlinkIDModule overlayViewControllerDidFinishScanning:state:] + 416
8 Trakku 0x000000010564d964 -[MBBlinkIdOverlaySettingsSerialization blinkIdOverlayViewControllerDidFinishScanning:state:] + 104
9 BlinkID 0x00000001094579dc $sSo25NSMutableAttributedStringC7BlinkIDE6string5style4fontABSS_So16NSParagraphStyleCSo6UIFontCtcfc + 673556
10 UIKitCore 0x00000001914fda80 B0858D8E-7220-37BF-873F-ECC2B0A358C3 + 846464
11 UIKitCore 0x00000001914fc9dc B0858D8E-7220-37BF-873F-ECC2B0A358C3 + 842204
12 UIKitCore 0x00000001914fc0f8 B0858D8E-7220-37BF-873F-ECC2B0A358C3 + 839928
13 QuartzCore 0x00000001908f7a5c 0AE8CEB8-0DD6-363F-951D-16AAC60A0951 + 80476
14 libdispatch.dylib 0x0000000196889eac B74732B5-D7FE-34A4-9346-41945701F020 + 16044
15 libdispatch.dylib 0x00000001968986a4 B74732B5-D7FE-34A4-9346-41945701F020 + 75428
16 libdispatch.dylib 0x00000001968982f4 _dispatch_main_queue_callback_4CF + 44
17 CoreFoundation 0x000000018f459d18 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 625944
18 CoreFoundation 0x000000018f43b650 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 501328
19 CoreFoundation 0x000000018f4404dc CFRunLoopRunSpecific + 612
20 GraphicsServices 0x00000001ca6ac35c GSEventRunModal + 164
21 UIKitCore 0x00000001917cc37c B0858D8E-7220-37BF-873F-ECC2B0A358C3 + 3789692
22 UIKitCore 0x00000001917cbfe0 UIApplicationMain + 340
23 Trakku 0x0000000104e9d948 main + 96
24 dyld 0x00000001ae8d4dec 41605DC7-F412-37D1-B51B-FEE1A26701E9 + 89580

@aarango
Copy link
Author

aarango commented May 29, 2023

wide the error information -

Your app just crashed. See the error below.
NSInvalidArgumentException: -[MBDate originalDateStringResult]: unrecognized selector sent to instance 0x2828a4b10 0 CoreFoundation 0x00000001b61b2da0 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 40352 1 libobjc.A.dylib 0x00000001af2703d0 objc_exception_throw + 60 2 CoreFoundation 0x00000001b6327b14 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 1567508 3 CoreFoundation 0x00000001b61c91c8 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 131528 4 CoreFoundation 0x00000001b622f9f0 _CF_forwarding_prep_0 + 96 5 Trakku 0x00000001035c3cb8 +[MBSerializationUtils serializeMBDateResult:] + 212 6 Trakku 0x00000001035c06c0 -[MBIdBarcodeRecognizer(JsonSerialization) serializeResult] + 684 7 Trakku 0x00000001035b6528 -[MBBlinkIDModule overlayViewControllerDidFinishScanning:state:] + 416 8 Trakku 0x00000001035b9844 -[MBBlinkIdOverlaySettingsSerialization blinkIdOverlayViewControllerDidFinishScanning:state:] + 104 9 BlinkID 0x00000001078cb9dc $sSo25NSMutableAttributedStringC7BlinkIDE6string5style4fontABSS_So16NSParagraphStyleCSo6UIFontCtcfc + 673556 10 UIKitCore 0x00000001b82e5a80 B0858D8E-7220-37BF-873F-ECC2B0A358C3 + 846464 11 UIKitCore 0x00000001b82e49dc B0858D8E-7220-37BF-873F-ECC2B0A358C3 + 842204 12 UIKitCore 0x00000001b82e40f8 B0858D8E-7220-37BF-873F-ECC2B0A358C3 + 839928 13 QuartzCore 0x00000001b76dfa5c 0AE8CEB8-0DD6-363F-951D-16AAC60A0951 + 80476 14 libdispatch.dylib 0x00000001bd671eac B74732B5-D7FE-34A4-9346-41945701F020 + 16044 15 libdispatch.dylib 0x00000001bd6806a4 B74732B5-D7FE-34A4-9346-41945701F020 + 75428 16 libdispatch.dylib 0x00000001bd6802f4 _dispatch_main_queue_callback_4CF + 44 17 CoreFoundation 0x00000001b6241d18 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 625944 18 CoreFoundation 0x00000001b6223650 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 501328 19 CoreFoundation 0x00000001b62284dc CFRunLoopRunSpecific + 612 20 GraphicsServices 0x00000001f149435c GSEventRunModal + 164 21 UIKitCore 0x00000001b85b437c B0858D8E-7220-37BF-873F-ECC2B0A358C3 + 3789692 22 UIKitCore 0x00000001b85b3fe0 UIApplicationMain + 340 23 Trakku 0x0000000102e096c8 main + 96 24 dyld 0x00000001d56bcdec 41605DC7-F412-37D1-B51B-FEE1A26701E9 + 89580

Este es un ejemplo del código en que estamos utilizando

`import React from 'react'
import * as BlinkIDReactNative from 'blinkid-react-native'
import { View, Platform, Image, Dimensions } from 'react-native'
import Constants from 'expo-constants'
import { styles } from './styles'
import { ButtonApp, Card, CustomText } from '@auteco/components/shared'
import { useCounter } from '@auteco/hooks'
import { useNavigation } from '@react-navigation/native'
import { screenNames } from '@auteco/constans'
import { Colors } from '@auteco/theme'
import { shared } from '@auteco/assets'

const licenseKey = Platform.select({
ios: Constants.manifest.extra.iosApiKeyBlinkId,
android: Constants.manifest.extra.androidBlinkIdApiKey,
})

const { height } = Dimensions.get('window')

function ScanCodeQRDriver({ onScanResult }) {
const { handleUpdateStep } = useCounter()
const navigation = useNavigation()

async function scan() {
try {
await handleUpdateStep(2)
const uiSettings = new BlinkIDReactNative.BlinkIdOverlaySettings()
uiSettings.firstSideInstructionsText = 'Apunta al código QR'
uiSettings.secondSideInstructionsText = 'Voltea y apunta al código QR'
uiSettings.scanBarcodeText = 'Escaneando...'

  const idBarcodeRecognizer = new BlinkIDReactNative.IdBarcodeRecognizer()
  // idBarcode.recognizerType = 'qr'
  const scanningResults = await BlinkIDReactNative.BlinkID.scanWithCamera(
    uiSettings,

    new BlinkIDReactNative.RecognizerCollection([idBarcodeRecognizer]),
    licenseKey,
    20000,
  )
  if (scanningResults) {
    // setIsResult(false)
    onScanResult(scanningResults[0]?.stringData)
  } else {
    console.log('else')
  }
} catch (error) {}

}

return (



Lectura código QR Conductor


Prepára el código QR que se muesta a continuación, este código QR lo
recibiste de la persona propietaria del vehículo.

<Image
source={shared.classic}
style={{
width: '100%',
height: height * 0.35,
resizeMode: 'stretch',
}}
/>


<ButtonApp
onPress={() => scan()}
text='Escanear código QR'
color='#48B2E8'
/>
<ButtonApp
onPress={() => navigation.navigate(screenNames.LOGIN)}
text='Salir del registro'
color={Colors.BACKGROUND_CIAN}
/>


)
}

export { ScanCodeQRDriver }
`

Y este es el código ejemplo de la implementación en IOS

require File.join(File.dirname(node --print "require.resolve('expo/package.json')"), "scripts/autolinking") require File.join(File.dirname(node --print "require.resolve('react-native/package.json')"), "scripts/react_native_pods") require File.join(File.dirname(node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(dir, 'Podfile.properties.json'))) rescue {}

platform :ios, podfile_properties['ios.deploymentTarget'] || '13.0'
install! 'cocoapods',
:deterministic_uuids => false

target 'Trakku' do
use_expo_modules!
config = use_native_modules!

use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']

Flags change depending on the env values.

flags = get_default_flags()

pod 'Firebase', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true

React Native Maps dependencies

rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'blinkid-react-native', :path => '../node_modules/blinkid-react-native'
#pod 'PPBlinkID', '~> 5.15.0'
pod 'RNSVG', :path => '../node_modules/react-native-svg'

use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes',
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/..",
#
# Uncomment to opt-in to using Flipper
# Note that if you have use_frameworks! enabled, Flipper will not work
# :flipper_configuration => !ENV['CI'] ? FlipperConfiguration.enabled : FlipperConfiguration.disabled,
)

post_install do |installer|
react_native_post_install(
installer,
# Set mac_catalyst_enabled to true in order to apply patches
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)

# This is necessary for Xcode 14, because it signs resource bundles by default
# when building for devices.
installer.target_installation_results.pod_target_installation_results
  .each do |pod_name, target_installation_result|
  target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
    resource_bundle_target.build_configurations.each do |config|
      config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
    end
  end
end

end

post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
end

Dependencies

"dependencies": {
"@babel/runtime": "^7.20.1",
"@expo/vector-icons": "^13.0.0",
"@googlemaps/polyline-codec": "^1.0.28",
"@gorhom/bottom-sheet": "^4.4.5",
"@gorhom/portal": "^1.0.14",
"@react-native-community/netinfo": "9.3.5",
"@react-native-masked-view/masked-view": "0.2.8",
"@react-native-picker/picker": "2.4.8",
"@react-navigation/native": "^6.0.14",
"@react-navigation/native-stack": "^6.9.2",
"axios": "^1.1.3",
"blinkid-react-native": "^6.1.1",
"dotenv": "^16.0.3",
"eslint-config-prettier": "^8.5.0",
"expo": "~47.0.14",
"expo-app-loading": "~2.1.1",
"expo-asset": "~8.7.0",
"expo-barcode-scanner": "~12.1.0",
"expo-blur": "~12.0.1",
"expo-build-properties": "~0.4.1",
"expo-camera": "~13.1.0",
"expo-checkbox": "~2.2.2",
"expo-constants": "~14.0.2",
"expo-contacts": "~11.0.1",
"expo-dev-client": "~2.0.1",
"expo-device": "~5.0.0",
"expo-error-recovery": "~4.0.1",
"expo-firebase-analytics": "~8.0.0",
"expo-font": "~11.0.1",
"expo-linear-gradient": "~12.0.1",
"expo-linking": "~3.3.1",
"expo-location": "~15.0.1",
"expo-network": "~5.0.0",
"expo-notifications": "~0.17.0",
"expo-permissions": "~14.0.0",
"expo-secure-store": "~12.0.0",
"expo-sharing": "~11.0.1",
"expo-splash-screen": "~0.17.5",
"expo-status-bar": "~1.4.2",
"expo-store-review": "~6.0.0",
"expo-system-ui": "~2.0.1",
"expo-updates": "~0.15.6",
"lodash": "^4.17.21",
"metro-react-native-babel-preset": "^0.73.3",
"prop-types": "^15.8.1",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-native": "0.70.8",
"react-native-app-intro-slider": "^4.0.4",
"react-native-autocomplete-dropdown": "^2.1.0",
"react-native-barcode-mask": "^1.2.4",
"react-native-btr": "^2.2.0",
"react-native-calendars": "^1.1291.1",
"react-native-gesture-handler": "~2.8.0",
"react-native-map-link": "^2.10.2",
"react-native-maps": "1.3.2",
"react-native-pager-view": "6.0.1",
"react-native-picker-select": "^8.0.4",
"react-native-qrcode-svg": "^6.1.2",
"react-native-reanimated": "~2.12.0",
"react-native-recaptcha-that-works": "^1.3.2",
"react-native-safe-area-context": "4.4.1",
"react-native-screens": "~3.18.0",
"react-native-svg": "13.4.0",
"react-native-toast-message": "^2.1.6",
"react-native-walkthrough-tooltip": "^1.4.0",
"react-native-web": "~0.18.7",
"react-native-webview": "11.23.1"
#},`

@mparadina
Copy link
Contributor

Hi @aarango

We've managed to reproduce the issue on our end and are investigating why this behavior is happening.
Once I have more information, I will make a follow-up here.

@mparadina
Copy link
Contributor

Hi @aarango

We found out what was causing the IDBarcode recognizer issue, which will be fixed in the upcoming releases.
Until then, I can suggest a workaround to resolve the issue on your end.

First, you need to locate the MBSerializationUtils.m file in the blinkid-react-native node module.
The path is:
.../node_modules/blinkid-react-native/src/ios/MicroblinkModule/MicroblinkModule/MBSerializationUtils.m

In the file, you just need to comment out line 27:
[dict setValue:[MBSerializationUtils serializeMBStringResult:value.originalDateStringResult] forKey:@"originalDateStringResult"];

After you comment it out, the crash will not appear anymore.

If this method is not an option, I can recommend using our BlinkID Single Side recognizer, which contains all of the functionalities of the IDBarcode recognizer. You can limit it to only extracting the information from the barcodes.

This is a sample implementation of the recognizer to only extract the barcode information:
Setting up the recognizer:

var blinkIdSingleSideRecognizer = new BlinkIDReactNative.BlinkIdSingleSideRecognizer();

var filter = new BlinkIDReactNative.RecognitionModeFilter();
      filter.enableBarcodeId = true;

      filter.enableMrzId = false;
      filter.enableMrzVisa = false;
      filter.enableMrzPassport = false;
      filter.enablePhotoId = false;
      filter.enableFullDocumentRecognition = false; 

   blinkIdSingleSideRecognizer.recognitionModeFilter = filter;

 const scanningResults = await BlinkIDReactNative.BlinkID.scanWithCamera(
                new BlinkIDReactNative.BlinkIdOverlaySettings(),
                new BlinkIDReactNative.RecognizerCollection([blinkIdSingleSideRecognizer]),
                licenseKey
            );

Handling the results:

if (result instanceof BlinkIDReactNative.BlinkIdSingleSideRecognizerResult){
            console.log(result.barcodeResult.stringData); 
}

All of the information you can obtain from the barcodeResult can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants