【问题标题】:New Window Pop not working in iOS flutter_inappwebview while doing Payment from RazorPAY从 RazorPAY 付款时,新窗口弹出在 iOS flutter_inappwebview 中不起作用
【发布时间】:2022-11-10 19:37:18
【问题描述】:

我在这里使用一个 Web URL 进行 RazorPay 付款。有 razorpay_plugin 但由于某些要求,我想从 Web URL 集成。 对于在 flutter_inappwebview 插件中使用的 WebView 我。在 android 中,Razor Pay 测试模式弹出新窗口并显示成功和失败选项

但对于 iOS,Web URL 不会在新的弹出窗口中打开。

在 Info.plist 中添加了这些权限

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

但仍然无法正常工作。

这是代码。


class SomeScreen extends StatefulWidget {
  final String url;
  const SomeScreen({Key? key, required this.url}) : super(key: key);

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

class _SomeScreenState extends State<SomeScreen> {
  InAppWebViewController? _webViewController;
  InAppWebViewController? _webViewPopupController;
  late String url;
  final options = InAppWebViewGroupOptions(
    crossPlatform: InAppWebViewOptions(
        javaScriptCanOpenWindowsAutomatically: true,
        javaScriptEnabled: true,
        useOnDownloadStart: true,
        useOnLoadResource: true,
        preferredContentMode: UserPreferredContentMode.MOBILE,
        useShouldOverrideUrlLoading: true,
        mediaPlaybackRequiresUserGesture: true,
        allowFileAccessFromFileURLs: true,
        allowUniversalAccessFromFileURLs: true),
    android: AndroidInAppWebViewOptions(
      supportMultipleWindows: true,
    ),
    ios: IOSInAppWebViewOptions(
      allowsAirPlayForMediaPlayback: true,
      suppressesIncrementalRendering: true,
      ignoresViewportScaleLimits: true,
      selectionGranularity: IOSWKSelectionGranularity.DYNAMIC,
      isPagingEnabled: true,
      enableViewportScale: true,
      sharedCookiesEnabled: true,
      automaticallyAdjustsScrollIndicatorInsets: true,
      useOnNavigationResponse: true,
      allowsInlineMediaPlayback: true,
    ),
  );

  @override
  void initState() {
    super.initState();
    url = widget.url;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Container(
          child: InAppWebView(
            initialUrlRequest: URLRequest(url: Uri.parse(widget.url)),
            initialOptions: options,
            onWebViewCreated: (InAppWebViewController controller) {
              _webViewController = controller;
            },
            iosOnNavigationResponse: (controller, response) async {
              return IOSNavigationResponseAction.ALLOW;
            },

            onLoadStart: (controller, Uri? uri) {
              print("Load Started: $uri");
            },
            onCreateWindow: (controller, createWindowRequest) async {
              showDialog(
                context: context,
                builder: (context) {
                  return AlertDialog(
                    content: SizedBox(
                      width: MediaQuery.of(context).size.width,
                      height: 400,
                      child: InAppWebView(
                        // Setting the windowId property is important here!
                        windowId: createWindowRequest.windowId,
                        initialOptions: options,
                        onWebViewCreated: (InAppWebViewController controller) {
                          _webViewPopupController = controller;
                        },

                        onLoadStart:
                            (InAppWebViewController controller, Uri? url) {
                          print("onLoadStart popup $url");
                        },
                        onLoadStop:
                            (InAppWebViewController controller, Uri? url) {
                          print("onLoadStop popup $url");
                          
                        },
                      ),
                    ),
                  );
                },
              );

              return true;
            },
          ),
        ),
      ),
    );
  }

}

【问题讨论】:

    标签: ios flutter webview flutter-ios flutter-inappwebview


    【解决方案1】:

    嗨@Agnel你找到解决方案了吗?我有同样的问题

    【讨论】:

    猜你喜欢
    • 2021-06-08
    • 2021-02-07
    • 2019-04-09
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    • 2016-12-25
    • 2017-01-09
    • 1970-01-01
    相关资源
    最近更新 更多