Siri : IntentHandler not behaving correctly with device Touch ID

给你一囗甜甜゛ 提交于 2019-12-11 05:18:14

问题


What is the right approach to handle device LocalAuthentication with NSIntent? Currently it is not showing payment sent pop up in Siri INSendPaymentIntent.

- (void)handleSendPayment:(INSendPaymentIntent *)intent
           completion:(void (^)(INSendPaymentIntentResponse *response))completion {

        __block INSendPaymentIntentResponse *siriResponse;

        LAContext *context = [[LAContext alloc] init];
        NSError *error = nil;

        // Check if device supports TouchID
        if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {

            // TouchID supported, show it to user
            [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics

                    localizedReason:@"Unlock using Touch ID to transaction”
                              reply:^(BOOL success, NSError *error) {

                                  if (success) {
                                      // This action has to be on main thread and must be synchronous
                                      dispatch_async(dispatch_get_main_queue(), ^{
                                        //  Payment handling code goes here
                                      });
                                  }
                                  else if (error) {
                                      dispatch_async(dispatch_get_main_queue(), ^{
                                          siriResponse = [[INSendPaymentIntentResponse alloc] initWithCode:INSendPaymentIntentResponseCodeSuccess userActivity:nil];
                                      });
                                  }
                              }];
        }
}

If I remove Local Authentication payment works just fine!!

来源:https://stackoverflow.com/questions/39686056/siri-intenthandler-not-behaving-correctly-with-device-touch-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!