Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework TouchID的方法isAvailable()不存在!(2)_Ionic Framework_Ionic2 - Fatal编程技术网

Ionic framework TouchID的方法isAvailable()不存在!(2)

Ionic framework TouchID的方法isAvailable()不存在!(2),ionic-framework,ionic2,Ionic Framework,Ionic2,我试图在ionic 2中测试TouchID,但它不起作用 export class HomePage { private touchIdAvailable: boolean; constructor(public _navCtrl: NavController, private _platform: Platform) { this._platform.ready().then(() => { TouchID.isAvailable().then(

我试图在ionic 2中测试TouchID,但它不起作用

    export class HomePage {

  private touchIdAvailable: boolean;

  constructor(public _navCtrl: NavController, private _platform: Platform) {
    this._platform.ready().then(() => {
      TouchID.isAvailable().then(
        res => alert('ok'),
        err => alert('not ok')
      );

      this.touchIdAvailable = true;
    })
  }


  private startTouchID() {
    TouchID.verifyFingerprint('Fingerprints are Awesome')
      .then(
        res => alert('Pass'),
        err => alert('Not Pass')
      );
  }
}
此代码不起作用。因此,如果我对代码的这一部分进行注释,它会起作用

    this._platform.ready().then(() => {
      //TouchID.isAvailable().then(
      //  res => alert('tem'),
      //  err => alert('nao tem')
      //);

      this.touchIdAvailable = true;
    })
我发现错误:我找到的“typeof TouchID”上不存在Proprety“isavailable()”

第46行的/node_模块/ionic native/dist/plugins/touchid.d.ts中I更改:

isAvailable(): Promise<any>;
isAvailable():承诺;
为此:

static isAvailable(): Promise<any>;
static isAvailable():Promise;

您不必编辑
节点模块/ionic native/dist/plugins/touchid.d.ts

只需在构造函数中初始化
TouchId
实例

  constructor(
    private touchId: TouchID
  ) {
    this.platform.ready().then(() => {
      this.touchId.isAvailable().then(
        res => this.touchIdAvailable = true,
        err => this.touchIdAvailable = false
      );          
    })
  }

从“ionic native”导入{TouchID};//用这个来导入@SandePharma,我已经在做了。这就是代码的第二部分(startTouchID())工作的原因。只有TouchID.isAvailable()不起作用。