Search code examples
iosswiftiphonein-app-purchasesubscription

How to use FaceID on In-App-Purchase Sub. rather then entering Password?


I am trying to add FaceID on IAP in my application for subscription with help of Double click of side Button. I added Privacy - Face ID Usage Description in info-plist and I have code:

let context = LAContext() var error: NSError?

    if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
        let reason = "Enable FaceID!"

        context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) {
            [unowned self] (success, authenticationError) in

            DispatchQueue.main.async {
                if success {
                    print("FaceID Acccessed!")
                } else {
                    // error
                    print("FaceID Declined!")
                }
            }
        }
    } else {
        // no biometry
    }

I don't know where to add it.

I tried to add swifty StoreKit as well but haven't found anything related to IAP popup. Please Help me Guy's. I spent whole day but couldn't edit IAP popup. Thanks

enter image description here]


Solution

  • There is nothing you need to do or can do in your code for this.

    The in app purchase process is handled by iOS once you submit the purchase request.

    The purchase process will prompt the user to authenticate with biometrics if this option is available based on the user's settings and the device capabilities.

    You will never get a biometric authentication for a sandbox purchase.