ASAuthorizationController AuthorizationError Code=1004 "(null)",当尝试访问 iOS 生物识别身份验证时

问题描述 投票:0回答:1

所以我正在使用 inappwebview 的 flutter 应用程序中工作,这是应用程序中的一个简单的导航器,允许用户直接从本机应用程序访问网络平台(公司请求)。

尝试访问的应用程序具有生物识别身份验证作为向用户授予访问权限的选项。

问题是该应用程序没有访问生物识别凭据的权限,而且我不知道如何授予它们。我已将登录功能添加到 xcode 中的所有(发布、调试和配置文件)阶段,以及 Info.plist 的

NSFaceIDUsageDescription

这是 xcode 在 flutter 应用中点击 activate 时显示的错误。

ASAuthorizationController credential request failed with error: Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1004 "(null)"

应用程序错误

enter image description here

预期的行为,这就是尝试从普通浏览器访问并单击“激活”时发生的情况 enter image description here

这是启动 inappwebview 的 flutter 代码

    import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'dart:io' show Platform;

class HomePageWidget extends StatefulWidget {
  const HomePageWidget({super.key});

  @override
  _HomePageWidgetState createState() => _HomePageWidgetState();
}

class _HomePageWidgetState extends State<HomePageWidget> {
  late MyInAppBrowser browser;
  final settings = InAppBrowserClassSettings(
      browserSettings: InAppBrowserSettings(
          hideToolbarBottom: true,
          hideCloseButton: true,
          hideUrlBar: true,
          hideTitleBar: true,
          hideDefaultMenuItems: true,
          presentationStyle: ModalPresentationStyle.OVER_FULL_SCREEN),
      webViewSettings: InAppWebViewSettings(
      
        userAgent: Platform.isAndroid
            ? "Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.82 Mobile Safari/537.36"
            : "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1",
        cacheEnabled: true,
        javaScriptEnabled: true,
        isElementFullscreenEnabled: true,
      ));
  // Assuming this is the correct type

  @override
  void initState() {
    super.initState();
    browser = MyInAppBrowser(onBrowserExit: () {
      setState(() {
        // Handle browser exit if needed
      });
    });
    openBrowser();
  }

  void openBrowser() async {
    await browser.openUrlRequest(
        urlRequest: URLRequest(
            url: WebUri(
                "https://linktowebapp")), 
        settings: settings);
    // Additional logic if necessary
  }

  @override
  Widget build(BuildContext context) {
    // Your build method as before, but replace the onPressed method:
    return const Scaffold(
      body: Center(),
    );
  }
}

// Modify the MyInAppBrowser class to accept a callback
class MyInAppBrowser extends InAppBrowser {
  final VoidCallback onBrowserExit;

  MyInAppBrowser({required this.onBrowserExit});

  @override
  void onExit() {
    super.onExit();
    print("Browser closed!");
    onBrowserExit(); // Call the provided callback
  }

  // The rest of your MyInAppBrowser implementation...
}
ios flutter xcode
1个回答
0
投票

您的问题实际上与密钥有关,而不是生物识别身份验证本身。

NSFaceIDUsageDescription
info.plist 条目与应用程序中 LocalAuthentication 框架的使用相关。

Flutter 的

inappwebview
在幕后使用 iOS 的
WKWebView

Apple 已提供 说明 以支持

WKWebView
中的密钥:

要在 WKWebView Web 视图中使用密钥进行身份验证,请将服务的依赖方标识符配置为应用程序中的关联域。有关更多信息,请参阅支持关联域

您需要从网站获取依赖方标识符,并将其作为关联域添加到您的 info.plist 文件中。

© www.soinside.com 2019 - 2024. All rights reserved.