Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to automate touch ID or face ID using xcuitest in simulator?

Tags:

ios

xcuitest

Is there a way to automate face ID or Touch ID using xcuitest framework in simulator. Manually I can perform enrolling face/touch id and perform matching or non-matching scenarios. However I would like to know if it can be automated?

like image 669
sjgmamer Avatar asked Nov 30 '18 10:11

sjgmamer


1 Answers

Given this post by Kane Cheshire it is possible to automate touch ID and face ID for unit testing by sending a Darwin notification like so :

+ (void)enrolled {
  int token;
  notify_register_check("com.apple.BiometricKit.enrollmentChanged", &token);
  notify_set_state(token, 1);
  notify_post("com.apple.BiometricKit.enrollmentChanged");
}

Only in Objective-C though, so you may need to use a bridging header.

Import the files Biometrics.m and Biometrics.h from his demo on Gitub and you will be able to call Biometrics.enrolled() from your XCTestCase.

like image 65
Axel Guilmin Avatar answered Oct 05 '22 20:10

Axel Guilmin