@el173/react-native-passcode-auth

中文文档
1.0.1发布于 2020/05/04ISCCommonJS零依赖近 30 天下载 2145

用 iOS Passcode 进行本地认证 .

中文使用文档
文档目录10 节
  1. 安装
  2. 使用量
  3. 将图书馆连接起来(通过可可站)
  4. 请求密码认证
  5. 示例
  6. 方法
  7. 认证( 理由)
  8. 已支持 ()
  9. 错误
  10. 许可证

从 反应-内生-密码-自动

不在原重现中的更改

  • 为 iOS 添加了 postspec

反应原生密码 Auth

反应原生密码 Auth 是 原生反应 用于认证使用iOS Passcode的用户的库。 它是一个优秀的后退 对于何时 触摸身份证 无法获取.

react-native-passcode-auth

安装

反应原生密码 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", 并且授权 发布所有关于这个软件的警告, 包括所有包含的 危险和可识别性。 任何特别的、直接的、间接的、或因果的、或因使用、数据或方案的损失而产生的任何特别的、直接的、间接的、或因果的、或因果的、或因使用、数据或方案而造成的任何损失,或因使用或执行本软件而产生的任何特别的、直接的、间接的、间接的、或因果的、间接的、或因果的、或因使用、数据或方案而造成的任何特别、直接的、间接的、或因果的、间接的或因果的、或因果的、或因果的、或因果的、或因使用或执行本软件而产生的任何特别的、直接的、间接的、间接的或因果的或因果的或因果的、数据或因果的、数据或因果的、数据或因果的、数据或因果的、数据或因果的、数据或因果的、或因果的、或因果的、或因果的、或因果的、或因果的、或因果的、或因的、或因果的、或因果的、或因果的、或因果的.

版本与发布记录

@el173/react-native-passcode-auth 共发布 2 个版本,首次发布于 2020/05/04;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.1latest2020/05/046 年前
1.0.02020/05/046 年前

关于 @el173/react-native-passcode-auth 的常见问题

@el173/react-native-passcode-auth 是什么?

用 iOS Passcode 进行本地认证 .

如何安装 @el173/react-native-passcode-auth?

在项目目录运行 npm install @el173/react-native-passcode-auth,或使用 pnpm add / yarn add / bun add。

@el173/react-native-passcode-auth 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/el173__react-native-passcode-auth 是否存在。

@el173/react-native-passcode-auth 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@el173/react-native-passcode-auth 可以商用吗?

@el173/react-native-passcode-auth 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@el173/react-native-passcode-auth 的下载量有多少?

根据 npm 官方下载统计,@el173/react-native-passcode-auth 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,145 次,日均约 72 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@el173/react-native-passcode-auth 还在维护吗?

最新版本 1.0.1 发布于 2020/05/04(6 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/05/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。