├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── TouchId.js ├── ios └── RCTTouchId │ ├── RCTTouchId.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── RCTTouchId │ ├── RCTTouchId.h │ └── RCTTouchId.m └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | *.[aod] 2 | *.DS_Store 3 | .DS_Store 4 | *Thumbs.db 5 | *.iml 6 | .gradle 7 | .idea 8 | node_modules 9 | npm-debug.log 10 | /android/build 11 | /ios/**/*xcuserdata* 12 | /ios/**/*xcshareddata* -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | *.[aod] 2 | *.DS_Store 3 | .DS_Store 4 | *Thumbs.db 5 | *.iml 6 | .gradle 7 | .idea 8 | node_modules 9 | npm-debug.log 10 | /android/build 11 | /ios/**/*xcuserdata* 12 | /ios/**/*xcshareddata* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-smart-touch-id 2 | 3 | [![npm](https://img.shields.io/npm/v/react-native-smart-touch-id.svg)](https://www.npmjs.com/package/react-native-smart-touch-id) 4 | [![npm](https://img.shields.io/npm/dm/react-native-smart-touch-id.svg)](https://www.npmjs.com/package/react-native-smart-touch-id) 5 | [![npm](https://img.shields.io/npm/dt/react-native-smart-touch-id.svg)](https://www.npmjs.com/package/react-native-smart-touch-id) 6 | [![npm](https://img.shields.io/npm/l/react-native-smart-touch-id.svg)](https://github.com/react-native-component/react-native-smart-touch-id/blob/master/LICENSE) 7 | 8 | Smart authentication with the native Touch ID popup for React Native app. 9 | 10 | This component is compatible with React Native 0.25 and newer, only supports iOS. 11 | 12 | ## Preview 13 | 14 | ![react-native-smart-touch-id-preview][1] 15 | 16 | ## Installation 17 | 18 | ``` 19 | npm install react-native-smart-touch-id --save 20 | ``` 21 | 22 | ## Notice 23 | 24 | It can only be used greater-than-equal react-native 0.4.0 for ios, if you want to use the package less-than react-native 0.4.0, use `npm install react-native-smart-touch-id@untilRN0.40 --save` 25 | 26 | 27 | ## Installation (iOS) 28 | 29 | * Drag RCTTouchId.xcodeproj to your project on Xcode. 30 | 31 | * Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag libRCTTouchId.a from the Products folder inside the RCTTouchId.xcodeproj. 32 | 33 | * Look for Header Search Paths and make sure it contains $(SRCROOT)/../../../react-native/React as recursive. 34 | 35 | ## Full Demo 36 | 37 | see [ReactNativeComponentDemos][0] 38 | 39 | ## Usage 40 | 41 | ```js 42 | 43 | import React, { 44 | Component 45 | } from 'react' 46 | import { 47 | View, 48 | Text, 49 | Alert, 50 | StyleSheet 51 | } from 'react-native' 52 | 53 | import TouchId from 'react-native-smart-touch-id' 54 | import Button from 'react-native-smart-button' 55 | 56 | export default class TouchIdTest extends Component { 57 | 58 | render() { 59 | return ( 60 | 61 | 68 | 75 | 76 | ) 77 | } 78 | 79 | //_isSupported = () => { 80 | // TouchId.isSupported( (error) => { 81 | // if (error) { 82 | // Alert.alert('TouchId is not supported!') 83 | // } else { 84 | // Alert.alert('TouchId is supported!') 85 | // } 86 | // }) 87 | //} 88 | 89 | _isSupported = async () => { 90 | try { 91 | await TouchId.isSupported() 92 | Alert.alert('TouchId is supported!') 93 | } catch(e) { 94 | Alert.alert('TouchId is not supported!') 95 | } 96 | } 97 | 98 | //_trggerTouchId = () => { 99 | // let description = 'Verify the existing mobile phone fingerprint using the home key' 100 | // //let title //fallback button title will be default as 'Enter Password'(localized) 101 | // //let title = "" //fallback button will be hidden 102 | // let title = "Verify Password" //fallback button title will be 'Verify Password'(unlocalized) 103 | // TouchId.verify(description, title, (error) => { 104 | // if (error) { 105 | // if (error.message == '-3') { 106 | // //fallback button is pressed 107 | // Alert.alert('errorCode: ' + error.message + ' verify failed, user wants to ' + title) 108 | // } 109 | // else { 110 | // Alert.alert('errorCode: ' + error.message + ' verify failed') 111 | // } 112 | // } else { 113 | // Alert.alert('verify succeeded') 114 | // } 115 | // }) 116 | //} 117 | 118 | _trggerTouchId = async () => { 119 | let description = 'Verify the existing mobile phone fingerprint using the home key' 120 | //let title //fallback button title will be default as 'Enter Password'(localized) 121 | //let title = "" //fallback button will be hidden 122 | let title = "Verify Password" //fallback button title will be 'Verify Password'(unlocalized) 123 | try { 124 | await TouchId.verify({ 125 | description, 126 | title, 127 | }); 128 | //await TouchId.verify("123123123123"); 129 | Alert.alert('verify succeeded') 130 | } catch(e) { 131 | if (e.code == '-3') { 132 | //fallback button is pressed 133 | Alert.alert('errorCode: ' + e.code + ' verify failed, user wants to ' + title) 134 | } 135 | else { 136 | Alert.alert('errorCode: ' + e.code + ' verify failed') 137 | } 138 | } 139 | } 140 | 141 | } 142 | 143 | ``` 144 | 145 | ## Errors 146 | 147 | There are various reasons why authenticating with Touch ID may fail. 148 | Whenever calling Touch ID authentication fails, `TouchId.verify` will return an error code. 149 | 150 | More information on errors can be found in [Apple's Documentation][2]. 151 | 152 | [0]: https://github.com/cyqresig/ReactNativeComponentDemos 153 | [1]: http://cyqresig.github.io/img/react-native-smart-touch-id-preview-v1.0.2.gif 154 | [2]: https://developer.apple.com/library/prerelease/ios/documentation/LocalAuthentication/Reference/LAContext_Class/index.html#//apple_ref/c/tdef/LAError 155 | -------------------------------------------------------------------------------- /TouchId.js: -------------------------------------------------------------------------------- 1 | /* 2 | * A smart touch id for react-native apps 3 | * https://github.com/react-native-component/react-native-smart-touch-id/ 4 | * Released under the MIT license 5 | * Copyright (c) 2016 react-native-component 6 | */ 7 | 8 | import { 9 | NativeModules 10 | } from 'react-native' 11 | 12 | export default NativeModules.TouchId -------------------------------------------------------------------------------- /ios/RCTTouchId/RCTTouchId.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9F03E4411D40B01B0023205F /* RCTTouchId.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9F03E4401D40B01B0023205F /* RCTTouchId.h */; }; 11 | 9F03E4431D40B01B0023205F /* RCTTouchId.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F03E4421D40B01B0023205F /* RCTTouchId.m */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXCopyFilesBuildPhase section */ 15 | 9F03E43B1D40B01B0023205F /* CopyFiles */ = { 16 | isa = PBXCopyFilesBuildPhase; 17 | buildActionMask = 2147483647; 18 | dstPath = "include/$(PRODUCT_NAME)"; 19 | dstSubfolderSpec = 16; 20 | files = ( 21 | 9F03E4411D40B01B0023205F /* RCTTouchId.h in CopyFiles */, 22 | ); 23 | runOnlyForDeploymentPostprocessing = 0; 24 | }; 25 | /* End PBXCopyFilesBuildPhase section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 9F03E43D1D40B01B0023205F /* libRCTTouchId.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTTouchId.a; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 9F03E4401D40B01B0023205F /* RCTTouchId.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTTouchId.h; sourceTree = ""; }; 30 | 9F03E4421D40B01B0023205F /* RCTTouchId.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTTouchId.m; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 9F03E43A1D40B01B0023205F /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | 9F03E4341D40B01B0023205F = { 45 | isa = PBXGroup; 46 | children = ( 47 | 9F03E43F1D40B01B0023205F /* RCTTouchId */, 48 | 9F03E43E1D40B01B0023205F /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | 9F03E43E1D40B01B0023205F /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | 9F03E43D1D40B01B0023205F /* libRCTTouchId.a */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | 9F03E43F1D40B01B0023205F /* RCTTouchId */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 9F03E4401D40B01B0023205F /* RCTTouchId.h */, 64 | 9F03E4421D40B01B0023205F /* RCTTouchId.m */, 65 | ); 66 | path = RCTTouchId; 67 | sourceTree = ""; 68 | }; 69 | /* End PBXGroup section */ 70 | 71 | /* Begin PBXNativeTarget section */ 72 | 9F03E43C1D40B01B0023205F /* RCTTouchId */ = { 73 | isa = PBXNativeTarget; 74 | buildConfigurationList = 9F03E4461D40B01B0023205F /* Build configuration list for PBXNativeTarget "RCTTouchId" */; 75 | buildPhases = ( 76 | 9F03E4391D40B01B0023205F /* Sources */, 77 | 9F03E43A1D40B01B0023205F /* Frameworks */, 78 | 9F03E43B1D40B01B0023205F /* CopyFiles */, 79 | ); 80 | buildRules = ( 81 | ); 82 | dependencies = ( 83 | ); 84 | name = RCTTouchId; 85 | productName = RCTTouchId; 86 | productReference = 9F03E43D1D40B01B0023205F /* libRCTTouchId.a */; 87 | productType = "com.apple.product-type.library.static"; 88 | }; 89 | /* End PBXNativeTarget section */ 90 | 91 | /* Begin PBXProject section */ 92 | 9F03E4351D40B01B0023205F /* Project object */ = { 93 | isa = PBXProject; 94 | attributes = { 95 | LastUpgradeCheck = 0730; 96 | ORGANIZATIONNAME = cyqresig; 97 | TargetAttributes = { 98 | 9F03E43C1D40B01B0023205F = { 99 | CreatedOnToolsVersion = 7.3.1; 100 | }; 101 | }; 102 | }; 103 | buildConfigurationList = 9F03E4381D40B01B0023205F /* Build configuration list for PBXProject "RCTTouchId" */; 104 | compatibilityVersion = "Xcode 3.2"; 105 | developmentRegion = English; 106 | hasScannedForEncodings = 0; 107 | knownRegions = ( 108 | en, 109 | ); 110 | mainGroup = 9F03E4341D40B01B0023205F; 111 | productRefGroup = 9F03E43E1D40B01B0023205F /* Products */; 112 | projectDirPath = ""; 113 | projectRoot = ""; 114 | targets = ( 115 | 9F03E43C1D40B01B0023205F /* RCTTouchId */, 116 | ); 117 | }; 118 | /* End PBXProject section */ 119 | 120 | /* Begin PBXSourcesBuildPhase section */ 121 | 9F03E4391D40B01B0023205F /* Sources */ = { 122 | isa = PBXSourcesBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | 9F03E4431D40B01B0023205F /* RCTTouchId.m in Sources */, 126 | ); 127 | runOnlyForDeploymentPostprocessing = 0; 128 | }; 129 | /* End PBXSourcesBuildPhase section */ 130 | 131 | /* Begin XCBuildConfiguration section */ 132 | 9F03E4441D40B01B0023205F /* Debug */ = { 133 | isa = XCBuildConfiguration; 134 | buildSettings = { 135 | ALWAYS_SEARCH_USER_PATHS = NO; 136 | CLANG_ANALYZER_NONNULL = YES; 137 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 138 | CLANG_CXX_LIBRARY = "libc++"; 139 | CLANG_ENABLE_MODULES = YES; 140 | CLANG_ENABLE_OBJC_ARC = YES; 141 | CLANG_WARN_BOOL_CONVERSION = YES; 142 | CLANG_WARN_CONSTANT_CONVERSION = YES; 143 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 144 | CLANG_WARN_EMPTY_BODY = YES; 145 | CLANG_WARN_ENUM_CONVERSION = YES; 146 | CLANG_WARN_INT_CONVERSION = YES; 147 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 148 | CLANG_WARN_UNREACHABLE_CODE = YES; 149 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 150 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 151 | COPY_PHASE_STRIP = NO; 152 | DEBUG_INFORMATION_FORMAT = dwarf; 153 | ENABLE_STRICT_OBJC_MSGSEND = YES; 154 | ENABLE_TESTABILITY = YES; 155 | GCC_C_LANGUAGE_STANDARD = gnu99; 156 | GCC_DYNAMIC_NO_PIC = NO; 157 | GCC_NO_COMMON_BLOCKS = YES; 158 | GCC_OPTIMIZATION_LEVEL = 0; 159 | GCC_PREPROCESSOR_DEFINITIONS = ( 160 | "DEBUG=1", 161 | "$(inherited)", 162 | ); 163 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 164 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 165 | GCC_WARN_UNDECLARED_SELECTOR = YES; 166 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 167 | GCC_WARN_UNUSED_FUNCTION = YES; 168 | GCC_WARN_UNUSED_VARIABLE = YES; 169 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 170 | MTL_ENABLE_DEBUG_INFO = YES; 171 | ONLY_ACTIVE_ARCH = YES; 172 | SDKROOT = iphoneos; 173 | }; 174 | name = Debug; 175 | }; 176 | 9F03E4451D40B01B0023205F /* Release */ = { 177 | isa = XCBuildConfiguration; 178 | buildSettings = { 179 | ALWAYS_SEARCH_USER_PATHS = NO; 180 | CLANG_ANALYZER_NONNULL = YES; 181 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 182 | CLANG_CXX_LIBRARY = "libc++"; 183 | CLANG_ENABLE_MODULES = YES; 184 | CLANG_ENABLE_OBJC_ARC = YES; 185 | CLANG_WARN_BOOL_CONVERSION = YES; 186 | CLANG_WARN_CONSTANT_CONVERSION = YES; 187 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 188 | CLANG_WARN_EMPTY_BODY = YES; 189 | CLANG_WARN_ENUM_CONVERSION = YES; 190 | CLANG_WARN_INT_CONVERSION = YES; 191 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 192 | CLANG_WARN_UNREACHABLE_CODE = YES; 193 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 194 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 195 | COPY_PHASE_STRIP = NO; 196 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 197 | ENABLE_NS_ASSERTIONS = NO; 198 | ENABLE_STRICT_OBJC_MSGSEND = YES; 199 | GCC_C_LANGUAGE_STANDARD = gnu99; 200 | GCC_NO_COMMON_BLOCKS = YES; 201 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 202 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 203 | GCC_WARN_UNDECLARED_SELECTOR = YES; 204 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 205 | GCC_WARN_UNUSED_FUNCTION = YES; 206 | GCC_WARN_UNUSED_VARIABLE = YES; 207 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 208 | MTL_ENABLE_DEBUG_INFO = NO; 209 | SDKROOT = iphoneos; 210 | VALIDATE_PRODUCT = YES; 211 | }; 212 | name = Release; 213 | }; 214 | 9F03E4471D40B01B0023205F /* Debug */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | HEADER_SEARCH_PATHS = ( 218 | "$(inherited)", 219 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 220 | "$(SRCROOT)/../../../react-native/React/**", 221 | ); 222 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 223 | OTHER_LDFLAGS = "-ObjC"; 224 | PRODUCT_NAME = "$(TARGET_NAME)"; 225 | SKIP_INSTALL = YES; 226 | }; 227 | name = Debug; 228 | }; 229 | 9F03E4481D40B01B0023205F /* Release */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | HEADER_SEARCH_PATHS = ( 233 | "$(inherited)", 234 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 235 | "$(SRCROOT)/../../../react-native/React/**", 236 | ); 237 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 238 | OTHER_LDFLAGS = "-ObjC"; 239 | PRODUCT_NAME = "$(TARGET_NAME)"; 240 | SKIP_INSTALL = YES; 241 | }; 242 | name = Release; 243 | }; 244 | /* End XCBuildConfiguration section */ 245 | 246 | /* Begin XCConfigurationList section */ 247 | 9F03E4381D40B01B0023205F /* Build configuration list for PBXProject "RCTTouchId" */ = { 248 | isa = XCConfigurationList; 249 | buildConfigurations = ( 250 | 9F03E4441D40B01B0023205F /* Debug */, 251 | 9F03E4451D40B01B0023205F /* Release */, 252 | ); 253 | defaultConfigurationIsVisible = 0; 254 | defaultConfigurationName = Release; 255 | }; 256 | 9F03E4461D40B01B0023205F /* Build configuration list for PBXNativeTarget "RCTTouchId" */ = { 257 | isa = XCConfigurationList; 258 | buildConfigurations = ( 259 | 9F03E4471D40B01B0023205F /* Debug */, 260 | 9F03E4481D40B01B0023205F /* Release */, 261 | ); 262 | defaultConfigurationIsVisible = 0; 263 | }; 264 | /* End XCConfigurationList section */ 265 | }; 266 | rootObject = 9F03E4351D40B01B0023205F /* Project object */; 267 | } 268 | -------------------------------------------------------------------------------- /ios/RCTTouchId/RCTTouchId.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/RCTTouchId/RCTTouchId/RCTTouchId.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface RCTTouchId : NSObject 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /ios/RCTTouchId/RCTTouchId/RCTTouchId.m: -------------------------------------------------------------------------------- 1 | #import "RCTTouchId.h" 2 | #import 3 | #import 4 | 5 | @implementation RCTTouchId 6 | 7 | RCT_EXPORT_MODULE(TouchId); 8 | 9 | RCT_EXPORT_METHOD(verify:(NSDictionary *)options 10 | resolver:(RCTPromiseResolveBlock)resolve 11 | rejecter:(RCTPromiseRejectBlock)reject) 12 | { 13 | NSString *description; 14 | NSString *title; 15 | 16 | if(options != nil) { 17 | NSArray *keys = [options allKeys]; 18 | 19 | if([keys containsObject:@"description"]) { 20 | description = [options objectForKey:@"description"]; 21 | } 22 | if([keys containsObject:@"title"]) { 23 | title = [options objectForKey:@"title"]; 24 | } 25 | } 26 | 27 | if(description != nil) { 28 | LAContext *context = [[LAContext alloc] init]; 29 | context.localizedFallbackTitle = title; 30 | NSError *error; 31 | // TouchID is supported 32 | if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { 33 | [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics 34 | localizedReason:description 35 | reply:^(BOOL success, NSError *error) { 36 | //Authenticate failed 37 | if(error) { 38 | reject([NSString stringWithFormat:@"%ld", error.code], @"", nil); 39 | } 40 | else { 41 | resolve(@[[NSNull null]]); 42 | } 43 | }]; 44 | } 45 | // TouchID is not supported 46 | else { 47 | reject(@"", @"", nil); 48 | } 49 | } 50 | } 51 | 52 | RCT_EXPORT_METHOD(isSupported:(RCTPromiseResolveBlock)resolve 53 | rejecter:(RCTPromiseRejectBlock)reject) 54 | { 55 | LAContext *context = [[LAContext alloc] init]; 56 | NSError *error; 57 | // TouchID is supported 58 | if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { 59 | resolve(@[[NSNull null]]); 60 | } 61 | else { 62 | // TouchID is not supported 63 | reject(@"", @"", nil); 64 | } 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-smart-touch-id", 3 | "version": "1.1.1", 4 | "description": "Smart authentication with the native Touch ID popup for React Native app", 5 | "main": "TouchId.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/react-native-component/react-native-smart-touch-id.git" 12 | }, 13 | "keywords": [ 14 | "react-native", 15 | "smart", 16 | "touch", 17 | "id", 18 | "touch-id", 19 | "component" 20 | ], 21 | "author": "HISAME SHIZUMARU", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/react-native-component/react-native-smart-touch-id/issues" 25 | }, 26 | "homepage": "https://github.com/react-native-component/react-native-smart-touch-id#readme", 27 | "peerDependencies": { 28 | "react-native": ">=0.40.0" 29 | } 30 | } 31 | --------------------------------------------------------------------------------