Mourad Idrissi
Mourad Idrissi

Reputation: 3785

Using TouchID on simulator

I'm trying to use TouchID within my Ionic 2 app. I have an iphone 5c, so I can't test it on real device.

I imported the package :

import { TouchID } from 'ionic-native';

Then, I tested the first function (I already activated touchID in the hardware section of the emulator):

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

Everything works fine. Now what I would like to do, is testing this function :

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

It's possible to test it on emulator ? The emulator can listen to fingerprint action ?

Upvotes: 16

Views: 25728

Answers (4)

Jimba Tamang
Jimba Tamang

Reputation: 1335

Anyone who is using latest Xcode (version 12x), there is no Hardware menu, it's been replace by 'Feature`. So to enroll the touch id,

  1. Open simulator
  2. Go to Features -> Touch Id -> Enrolled

enter image description here

Upvotes: 16

user10294571
user10294571

Reputation:

In new versions of xCode:

  1. Enable Touch ID by clicking in emulator top menu-> Hardware -> Touch ID -> Enrolled
  2. Then to emulate Touch in emulator top menu -> Hardware -> Touch ID -> Matching/Non-matching Touch

Upvotes: 1

Mourad Idrissi
Mourad Idrissi

Reputation: 3785

This is my code @josé-neto

ngOnInit() {
      if(window["plugins"]){
        window["plugins"].touchid.isAvailable(
          function() {
              console.log("isAvailable ok !");
              window["plugins"].touchid.verifyFingerprint(
                'Scan your fingerprint please',
                function(msg) {console.log('verifyFingerprint ok: ' + JSON.stringify(msg))}, 
                function(msg) {console.log('verifyFingerprint not ok: ' + JSON.stringify(msg))} 
              );
          }, 
          function(msg) {
            console.log('isAvailable not ok: ' + JSON.stringify(msg))
          }
        );
      }
      else{
        console.log('window["plugins"] not ok');
      }
  }

in the console, It displays "isAvailable ok !" then executes the function verifyFingerprint. (it display :verifyFingerprint not ok: null). It's not waiting the user action (fingerprint)

Upvotes: 0

José Neto
José Neto

Reputation: 540

Yes is possible!

With the simulator open you click in Hardware -> Touch ID Enrolled to make the Touch ID active

Touch ID Enrolled

To test the Touch ID you go in Hardware -> Simulate Finger Touch -> Matching or Non-Matching

Simulate Finger Touch

Upvotes: 20

Related Questions