不在原重现中的更改
- 为 iOS 添加了 postspec
反应原生密码 Auth
反应原生密码 Auth 是 原生反应 用于认证使用iOS Passcode的用户的库。 它是一个优秀的后退 对于何时 触摸身份证 无法获取.

安装
反应原生密码 Auth 需要 iOS 9.0 或以后。 。 。 .
npm i --save @el173/react-native-passcode-auth
使用量
将图书馆连接起来(通过可可站)
在您的构建目标中添加以下行 Podfile
pod 'PasscodeAuth', :path => '../node_modules/@el173/react-native-passcode-auth'
然后运行 pod install
请求密码认证
一旦你把图书馆连起来,你就会想通过要求它提供给你的应用程序:
import PasscodeAuth from '@el173/react-native-passcode-auth';
请求密码认证和呼叫一样简单:
PasscodeAuth.authenticate('to demo this react-native component')
.then(success => {
// Success code
})
.catch(error => {
// Failure code
});
示例
在您的应用程序中使用 PasscodeAuth 通常会这样:
import React, { Component, AlertIOS, TouchableHighlight, View, Text } from 'react-native';
import PasscodeAuth form 'react-native-passcode-auth';
class YourComponent extends Component {
_pressHandler() {
PasscodeAuth.authenticate('to demo this react-native component')
.then(success => {
AlertIOS.alert('Authenticated Successfully');
})
.catch(error => {
AlertIOS.alert('Authentication Failed');
});
}
render() {
return (
<View>
...
<TouchableHighlight onPress={this._pressHandler}>
<Text>
Authenticate with Passcode
</Text>
</TouchableHighlight>
</View>
);
}
});
方法
认证( 理由)
试图用密码认证.
回返a Promise 对象.
参数
reason- 一个 选项String这为请求认证提供了明确的理由.
实例
PasscodeAuth.authenticate('to demo this react-native component')
.then(success => {
// Success code
console.log('User authenticated with Passcode');
})
.catch(error => {
// Failure code
console.log(error);
});
已支持 ()
验证是否支持密码 Auth 并设定了密码 .
回返a Promise 对象.
实例
PasscodeAuth.isSupported()
.then(supported => {
// Success code
console.log('Passcode Auth is supported.');
})
.catch(error => {
// Failure code
console.log(error);
});
错误
使用 Passcode 认证可能失败的原因多种多样. 当呼叫密码认证失败时, PasscodeAuth.authenticate 将返回代表原因的错误代码.
以下是可以返回的错误代码列表 :
| 代码 | 说明 |
|---|---|
LAErrorAuthenticationFailed | 由于用户未能提供有效证书,认证未能成功. |
LAErrorUserCancel | 用户取消了认证 - 例如, 用户在对话框中点击了 Cancel . |
LAErrorUserFallback | 认证被取消, 因为用户已按下后退按钮( Enter Phone) . |
LAErrorSystemCancel | 系统取消了认证—— 例如, 如果认证对话框启动时有另一个应用程序出现。 Name. |
LAErrorPasscodeNotSet | 无法启动认证, 因为密码没有设置在设备上 . |
PasscodeAuthNotSet | 无法启动认证, 因为密码没有设置在设备上 . |
PasscodeAuthNotSupported | 设备不支持 Passcode Auth . |
关于错误的更多信息,请访问 苹果的文档。 。 。 .
许可证
版权(c)2015年, 纳乌法尔·卡德洪姆
特此准许为任何目的使用、复制、修改和(或)分发这种软件,不论是否收费,但上述版权通知和这项许可通知须以所有副本印发.
软件被提供"AS IS", 并且授权 发布所有关于这个软件的警告, 包括所有包含的 危险和可识别性。 任何特别的、直接的、间接的、或因果的、或因使用、数据或方案的损失而产生的任何特别的、直接的、间接的、或因果的、或因果的、或因使用、数据或方案而造成的任何损失,或因使用或执行本软件而产生的任何特别的、直接的、间接的、间接的、或因果的、间接的、或因果的、或因使用、数据或方案而造成的任何特别、直接的、间接的、或因果的、间接的或因果的、或因果的、或因果的、或因果的、或因使用或执行本软件而产生的任何特别的、直接的、间接的、间接的或因果的或因果的或因果的、数据或因果的、数据或因果的、数据或因果的、数据或因果的、数据或因果的、数据或因果的、或因果的、或因果的、或因果的、或因果的、或因果的、或因果的、或因的、或因果的、或因果的、或因果的、或因果的.