We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Only iPad device (iOS version 17 and above ) createSignature method is crashing.
npm version: "react-native-biometrics": "^3.0.1",
import ReactNativeBiometrics from 'react-native-biometrics' let epochTimeSeconds = Math.round((new Date()).getTime() / 1000).toString() let payload = epochTimeSeconds + 'some message' const rnBiometrics = new ReactNativeBiometrics() rnBiometrics.createSignature({ promptMessage: 'Sign in', payload: payload }) .then((resultObject) => { const { success, signature } = resultObject if (success) { console.log(signature) verifySignatureWithServer(signature, payload) } })
Here is the iOS Native code
RCT_EXPORT_METHOD(createSignature: (NSDictionary *)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSString *promptMessage = [RCTConvert NSString:params[@"promptMessage"]]; NSString *payload = [RCTConvert NSString:params[@"payload"]]; NSData *biometricKeyTag = [self getBiometricKeyTag]; NSDictionary *query = @{ (id)kSecClass: (id)kSecClassKey, (id)kSecAttrApplicationTag: biometricKeyTag, (id)kSecAttrKeyType: (id)kSecAttrKeyTypeRSA, (id)kSecReturnRef: @YES, (id)kSecUseOperationPrompt: promptMessage }; SecKeyRef privateKey; OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&privateKey); if (status == errSecSuccess) { NSError *error; NSData *dataToSign = [payload dataUsingEncoding:NSUTF8StringEncoding]; NSData *signature = CFBridgingRelease(SecKeyCreateSignature(privateKey, kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA256, (CFDataRef)dataToSign, (void *)&error)); if (signature != nil) { NSString *signatureString = [signature base64EncodedStringWithOptions:0]; NSDictionary *result = @{ @"success": @(YES), @"signature": signatureString }; resolve(result); } else if (error.code == errSecUserCanceled) { NSDictionary *result = @{ @"success": @(NO), @"error": @"User cancellation" }; resolve(result); } else { NSString *message = [NSString stringWithFormat:@"Signature error: %@", error]; reject(@"signature_error", message, nil); } } else { NSString *message = [NSString stringWithFormat:@"Key not found: %@",[self keychainErrorToString:status]]; reject(@"storage_error", message, nil); } }); }
Please assist me on this. Do we need anything specific change required on iPad devices ?
Thanks in advance.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Only iPad device (iOS version 17 and above ) createSignature method is crashing.
npm version: "react-native-biometrics": "^3.0.1",
Here is the iOS Native code
Please assist me on this. Do we need anything specific change required on iPad devices ?
Thanks in advance.
The text was updated successfully, but these errors were encountered: