webview_flutter,新窗口弹出在IOS平台上不工作

o8x7eapl  于 12个月前  发布在  iOS
关注(0)|答案(1)|浏览(203)

当我点击我的网页视图中的一个按钮时,它会打开一个新的窗口,弹出网页,它会在Android设备中呈现,但在IOS中,它会在URL中给我“about:blank”,并显示空白屏幕,我已经尝试了不同的软件包,但这个问题仍然存在(webview_flutter,inappwebview)
而弹出应该呈现我得到的网址为“关于:空白”在IOS
我已经尝试了webview_flutter,inappwebview这两个软件包,并在info.plist中添加了所有属性

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>

字符串
这是我的web视图代码

@riverpod
 WebViewController webViewController(
 WebViewControllerRef ref, {
 required String url,
 TabController? tabController,
 bool isYodlee = false,
 bool isFromSubcritionPayment = false,
 String? currentPlaneCode,
 }) {
 bool loaderStarted = false;
 const params = PlatformWebViewControllerCreationParams();
 final WebViewController controller =
 WebViewController.fromPlatformCreationParams(params);
 controller
 ..setBackgroundColor(UIColors.backgroundPrimary)
 ..setJavaScriptMode(JavaScriptMode.unrestricted)
 ..setNavigationDelegate(
  NavigationDelegate(
    onProgress: (progress) {
      printLog('loading progress $progress%');
      if (!loaderStarted) {
        ref.read(loaderStateProvider.notifier).showLoader();
        loaderStarted = true;
      }
      if (progress == 100) {
        ref.read(loaderStateProvider.notifier).hideLoader();
        loaderStarted = false;
      }
    },
    onPageStarted: (String pageUrl) async {
      if (pageUrl.startsWith(SubscriptionConstants.successPage)) {
        ref.read(loaderStateProvider.notifier).hideLoader();
        if (isFromSubcritionPayment) {
          popUntilPath(currentContext, const 
 SubscriptionPurchaseSuccess());
        } else {
          Navigator.pop(currentContext);
          await cAlertDialog<void>(
            context: currentContext,
            title: Text(
              
 localization(currentContext).subscriptions.cardUpdateTitle,
            ),
            content: Text(
              
 localization(currentContext).subscriptions.cardUpdateContent,
            ),
          );
        }
        ref
          ..invalidate(aliveCurrentSubscriptionServiceProvider)
          ..invalidate(billIntervalUnitProvider)
          ..invalidate(nextPlanProvider);
      } else {
        ref.read(loaderStateProvider.notifier).showLoader();
      }
    },
    onPageFinished: (String url) async {
      ref.read(loaderStateProvider.notifier).hideLoader();
      // For yodlee to receive message
      if (isYodlee) {
        await controller
            .runJavaScript(BankConstants.yodleeAccountFetchScript);
      }
    },
    onWebResourceError: (error) {
      ref.read(loaderStateProvider.notifier).hideLoader();
      cAlertDialog<void>(
        context: currentContext,
        content: const Text('Failed to load the page!'),
      );
      currentContext.pop();
      printLog(error.description);
    },
  ),
 )
 ..addJavaScriptChannel(
  'Message',
  onMessageReceived: (JavaScriptMessage message) {
    // take the message and proceed to step 2 for yodlee
    if (isYodlee) {
      final data = YodleeWebResponse.fromJson(
        json.decode(message.message.replaceAll(r'\', '')) as JsonMap,
      );
      ref
          .read(newUnlinkedAccountsProvider.notifier)
          .getBankData(data)
          .then((value) {
        if (tabController != null) {
          tabController.animateTo(1);
        }
      });
    }
   },
   )
  ..loadRequest(Uri.parse(url));
 return controller;
 }

pbpqsu0x

pbpqsu0x1#

onNavigationRequest: (NavigationRequest request) {
        return NavigationDecision.navigate; //this work for me 
      },

字符串

相关问题