Plugin should use a background thread ( Terminating app due to uncaught exception 'NSInvalidArgumentException' )

Viewed 70

i am trying to use cordova keychain [plugin][1] for ios, inside my ionic application. but facing this error

6:48 PM2020-07-14 18:44:32.456726+0500 Farsh[1817:53270] THREAD WARNING: ['Keychain'] took '14.635986' ms. Plugin should use a background thread. 2020-07-14 18:44:32.456767+0500 Farsh[1817:55957] -[NSNull boolValue]: unrecognized selector sent to instance 0x7fff8062d9d0 2020-07-14 18:44:32.614153+0500 Farsh[1817:55957] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull boolValue]: unrecognized selector sent to instance 0x7fff8062d9d0' *** First throw call stack: ( 0 CoreFoundation 0x00007fff23e3cf0e __exceptionPreprocess + 350 1 libobjc.A.dylib 0x00007fff50ba89b2 objc_exception_throw + 48 2 CoreFoundation 0x00007fff23e5dc34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x00007fff23e4190c forwarding + 1436 4 CoreFoundation 0x00007fff23e43bf8 _CF_forwarding_prep_0 + 120 5 Farsh 0x000000010e66aac0 __19-[CDVKeychain set:]_block_invoke + 432 6 libdispatch.dylib 0x000000010e9c7f11 _dispatch_call_block_and_release

  • 12 7 libdispatch.dylib 0x000000010e9c8e8e _dispatch_client_callout + 8 8 libdispatch.dylib 0x000000010e9cb2d8 _dispatch_queue_override_invoke + 1022 9 libdispatch.dylib 0x000000010e9da399 _dispatch_root_queue_drain + 351 10 libdispatch.dylib 0x000000010e9daca6 _dispatch_worker_thread2 + 135 11 libsystem_pthread.dylib 0x00007fff51c089f7 _pthread_wqthread + 220 12 libsystem_pthread.dylib 0x00007fff51c07b77 start_wqthread + 15 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

and my application crashed after this. Is there anyone know how to solve this problem ?? Please answer Thanks in advance. [1]: https://ionicframework.com/docs/native/keychain

1 Answers

Solution

I had the same problem and the issue was that I didn't explicitly set a value for the useTouchId parameter. This bug is known since 2018 and still not fixed. Shows you how good ionic is as an ecosystem and how much the people care Worse is that even the official docs(!) have an incorrect example:

Wrong

this.keychain.set(key, value).then(() => { ... }

Correct

this.keychain.set(key, value, false).then(() => { ... }

Adding the third parameter should fix your issues.

Related