【问题标题】:Resume WebView if TouchID successful如果 TouchID 成功,则恢复 WebView
【发布时间】:2016-06-27 14:22:51
【问题描述】:

我想在我的 WebView 项目中使用 Touch ID。如果我的 webview 加载某个 url,我想显示 touchid 身份验证。我的问题是如何在认证成功后暂停和恢复加载?

我在“shouldStartLoadWithRequest”方法中有以下代码:

if([url isEqualToString:@"...=thisismyurl"]){ LAContext *myContext = [[LAContext alloc] init];
    NSError *authError = nil;
    NSString *myLocalizedReasonString = @"Please Authentificate";

    if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
        [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                  localizedReason:myLocalizedReasonString
                            reply:^(BOOL success, NSError *error) {
                                if (success) {
                                    // User authenticated successfully, take appropriate action
                                    ????
                                } else {
                                    // User did not authenticate successfully, look at error and take appropriate action
                                    NSLog(@"NEIN");
                                }
                            }];
    }}

重要提示:解决方案在我的最后一条评论中!

【问题讨论】:

  • 标题具有误导性。如果您的问题是暂停 webview 加载 url,那么为什么您的问题在 webview 中标题为 touch ID authentication?
  • 仅供参考,您可以对 webview 使用 stopLoading 和 startLoading,isLoading 方法。
  • 你说得对!是的,我现在用停止加载来测试它(你确定吗?开始加载不是有效的方法)。当我使用 loadRequest 时,我会一次又一次地看到 TouchID 提示
  • sry,你可以使用你可以使用 webview 的 stopLoading 和 loadRequest,isLoading 方法。
  • 是的,我使用 loadRequest。但现在我一次又一次地看到 TouchID 提示。问题:我用相同的 URL 调用 loadRequest...

标签: objective-c xcode uiwebview touch-id


【解决方案1】:

我有!现在我有一个 if 之前。有了这个 if 条件,程序可以查看调用是否来自按钮的示例。这是我的解决方案:

 if (navigationType == UIWebViewNavigationTypeFormSubmitted) { ... }

【讨论】:

    猜你喜欢
    • 2016-07-11
    • 2016-10-22
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    • 2016-11-05
    • 1970-01-01
    • 1970-01-01
    • 2011-01-17
    相关资源
    最近更新 更多