Forum Archive

Using FaceID

arandomperson

I'm trying to implement Face ID in a script, but following the example Touch ID scripts it just results in a crash, with faulthandler just saying Aborted

This is what i'm using,

from objc_util import *

context = ObjCClass('LAContext').alloc().init()
policy = 1
reason = "FaceID Testing"

def _handler(_cmd, success, error):
    autherr = ObjCInstance(error).localizedDescription()
    print(autherr)
    if success:
        print('authenicated')

handler = ObjCBlock(_handler,restype = None, argtypes = [c_void_p, c_void_p, c_void_p])
context.evaluatePolicy_localizedReason_reply_(policy, reason, handler)

Using the "canEvaluatePolicy:error:" function, it returns true, so i'm assuming that Face ID works.
Also setting policy to 2, defaults to passcode authentication.
Of course it can as simple as @omz not adding "NSFaceIDUsageDescription" to pythonista's Info.plist

Thanks for any help!

JonB

Well, your objc_block signature is wrong -- success (second argtypes) is a BOOL, not a c_void_p. BOOL in objc is a typedef for a signed char, or c_byte in ctypes. Note it is NOT c_bool.

arandomperson

@JonB oops my mistake, though it still crashes unfortunately.
Thanks for the reply!

JonB

does it still crash with the same seg fault?

JonB

try using None for the block, just to see if it crashes.

arandomperson

@JonB yeah, changing c_void_p to c_byte still results in a crash with the same fault log, and setting the handler to None also results in a crash with the same fault log.