本文介绍了在Ionic 2上使用TouchID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的Ionic 2应用程序中使用TouchID并使用此简化代码。

当我在iPhone上运行应用程序时,我看到控制台中记录了A,然后指纹或设备密码已验证。但是B未被记录。我错过了什么?

I am trying to use TouchID within my Ionic 2 app and have this simplified code.

When I run the app on my iPhone I see "A" is logged in the console and then "Fingerprint or device passcode validated."
but "B" is not logged. What have I missed?

checkIn(job) {
    console.log("A");
    TouchID.verifyFingerprint('Scan your fingerprint to check in')
    .then(
      res => function() {
        console.log("B");
      },
      err => alert('Sorry, your fingerprint is not recognised')
    );

}


推荐答案

我是假设您已使用

import { TouchID } from 'ionic-native';

在CheckIn功能中,首先使用

In your CheckIn function first check for Touch ID Availability using

TouchID.isAvailable()
.then(
  res => console.log('TouchID is available!'),
  err => console.error('TouchID is not available', err)
);

如果它记录'TouchID可用!'然后在您的TouchID.verifyFingerprint函数日志错误中查明问题

If it logs 'TouchID is available!' then in your TouchID.verifyFingerprint function log err to pinpoint the issue

TouchID.verifyFingerprint('Scan your fingerprint please')
.then(
  res => console.log('Ok', res),
  err => console.error('Error', err)
);

错误代码

该插件将拒绝由于各种原因。您的应用很可能需要以不同方式回应这些案例。

The plugin will reject for various reasons. Your app will most likely need to respond to the cases differently.

以下是一些错误代码的列表:

Here is a list of some of the error codes:


  • -1 - 指纹扫描失败超过3次

  • -2或-128 - 用户点击了取消按钮

  • -3 - 用户点击了输入密码或输入密码按钮

  • -4 - 系统取消了扫描(例如,主页按钮)

  • -6 - TouchID不可用

  • -8 - TouchID因尝试次数过多而被锁定

  • -1 - Fingerprint scan failed more than 3 times
  • -2 or -128 - User tapped the 'Cancel' button
  • -3 - User tapped the 'Enter Passcode' or 'Enter Password' button
  • -4 - The scan was cancelled by the system (Home button for example)
  • -6 - TouchID is not Available
  • -8 - TouchID is locked out from too many tries

这篇关于在Ionic 2上使用TouchID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-07 08:04