sparrowcode / PermissionsKit

Universal API for request permission and get its statuses.
https://x.com/sparrowcode_ios
MIT License
5.66k stars 462 forks source link

Face ID permission no return .authorized #251

Closed dan12411 closed 3 years ago

dan12411 commented 3 years ago

Should line 55 return .authorized? 🤔 Because I encounter the status stay .notDetermined and the controller would not dismiss automatically (which has set controller.dismissCondition = .allPermissionsDeterminated)

https://github.com/ivanvorobei/SPPermissions/blob/6618b3a84b8063c82652bee67ea47044b7bd46b0/Sources/SPPermissionsFaceID/SPFaceIDPermission.swift#L55

ivanvorobei commented 3 years ago

Here some problem. Line 55 not sure about status, its may be . notDetermined or allowed. Maybe you have idea how detect it correctly?

dan12411 commented 3 years ago

Hi, @ivanvorobei I think .allowed is better than .notDetermined, because device is allowed to use biometric authentication already, rather than notDetermined. To do that we can solve the controller not dismiss issue. 🤔 Thanks 🙏

ivanvorobei commented 3 years ago

@dan12411 when user first see Face ID, he see allowed state. Maybe it confused him.

dan12411 commented 3 years ago

@ivanvorobei The condition is isReady == true, means the user is passed the bio auth, so .allowed should not be confused, am I right?

  let isReady = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
  case nil where isReady:
    return .notDetermined

doc: https://developer.apple.com/documentation/localauthentication/lacontext/1514149-canevaluatepolicy

ivanvorobei commented 3 years ago

isReady property indicate if user has FaceID. It not same as allowed or not allowed for permission.

ivanvorobei commented 3 years ago

If you change it as you suggest, then even at first startup the user will see that permission has already been granted, although this is not the case.

There is really no way to check the current status of the FaceID permission. It works like this - if this is the first authorization attempt, permission will be shown. If it is the second and subsequent attempts, permission will not be requested. We don't know which attempt it is and there is no way to get that information.

ivanvorobei commented 3 years ago

I can add maybe flag or something else for have specific process for FaceID permission.

dan12411 commented 3 years ago

Got it, If the changed you suggest can dismiss the controller automatically will be great,

Thanks for your kindly reply : )

ivanvorobei commented 3 years ago

My idea this - for FaceID always show .notDetermined UI, but close controller with request even user not allow permission.