8

I have an Intent Extension with the View category that is working pretty good for showing an app info.

Now I need to enable TouchID for security reasons, so the user needs to authenticate before requesting the info.

I tried this:

func handle(intent: GetSaldoIntent, completion: @escaping (GetSaldoIntentResponse) -> Void) {

    let myContext = LAContext()

    myContext.evaluatePolicy(
    .deviceOwnerAuthenticationWithBiometrics,
    localizedReason: "Unlock to see the info",
    reply: { [unowned self] (success, error) -> Void in
        if( success ) {
            completion(GetSaldoIntentResponse.success(saldo: String(self.paymentProvider.balance)))
            return
            }
        })
        completion(GetSaldoIntentResponse(code: .failureRequiringAppLaunch, userActivity: nil))
    }
}

But the TouchID dialog closes the Siri screen and then the conversation ends:

screens

Is there a way to request for TouchId validation inside an Intent Extension?

I know PKPayment do something similar, but this isn't a transaction so I can't use ApplePay.

alxlives
  • 5,084
  • 4
  • 28
  • 50

1 Answers1

1

Siri already supports the authorisation, you just need to let Siri know that your intent requires authorisation rather implementing authorisation yourself. Hope that helps you:

https://developer.apple.com/documentation/sirikit/requesting_authorization_to_use_sirikit

Amir.n3t
  • 2,859
  • 3
  • 21
  • 28
  • This doesn't solved the issue because the `INPreferences.requestSiriAuthorization` is called from the app to the extension, and my problem is that I need a `LAContext().evaluatePolicy` from the extension without closing the Siri dialog. However, your link helped with `IntentsRestrictedWhileLocked`, so at least the user needs to unlock the screen before checking the infos. I will give you the bounty, but will leave this open in case someone can make this works properly. I will probably need an UI extension. – alxlives Oct 11 '19 at 14:32
  • @alxlives Unfortunately apple something messed up with this scenario, if you try to run it on a device with iOS 12 and below it will work just fine – mike vorisis Dec 09 '19 at 14:07