【问题标题】:Flutter webview is blank on IOS but working on androidFlutter webview 在 IOS 上是空白的,但在 android 上工作
【发布时间】:2021-10-01 14:11:12
【问题描述】:

我正在使用 Flutter webview 使用以下类在我的应用中显示付款网址:

class YourWebView extends StatelessWidget {
  String url;
  bool isFinshed = false;
  YourWebView(this.url);


  final Completer<WebViewController> _controller =
      Completer<WebViewController>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('اكمال عملية الدفع..'),
          leading: new IconButton(
              icon: new Icon(Icons.close),
              onPressed: () {
              
              if(isFinshed) {
                      Provider.of<MatchProvider>(context, listen: false)
                              .getMyComingMatches();
                        Navigator.of(context).popUntil((route) => route.isFirst);
              } else {
                
                Navigator.pop(context);
              }
               
              }),
        ),
        body: Builder(builder: (BuildContext context) {
          return WebView(
            initialUrl: Uri.encodeFull(url),
            javascriptMode: JavascriptMode.unrestricted,
            onWebViewCreated: (WebViewController webViewController) {
              _controller.complete(webViewController);
         
            },
            debuggingEnabled: true,
            onPageFinished: (String url) {
              SystemChannels.textInput.invokeMethod('TextInput.hide');
              
              if (url.contains("tap/check?tap_id")) {
                    
                     isFinshed = true;
              }
              print('Page finished loading: $url');
            },
            gestureRecognizers: null,
          //  gestureNavigationEnabled: false
          );
        }));
  }

网址如下所示: https://xxxxxx.com/tap/check?tap_id=chg_TS05162021120xxxxxxx

一切都在 Android 上运行,但在 IOS 上我得到一个空白屏幕,我在 xcode 调试日志中看到这个错误:

WebPageProxy::didFailProvisionalLoadForFrame

我尝试在 webview 上运行另一个 url 并且它正在运行,但付款 url 不是,即使它在 Android 或其他浏览器上运行。

【问题讨论】:

    标签: ios flutter webview


    【解决方案1】:

    我认为您可能尝试在 webview 中加载 http 链接而不是 https。在这种情况下,您应该在 info.plist 文件中添加以下内容。

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

    【讨论】:

    • 链接是https,我已经尝试过这个解决方案,但它不起作用..
    猜你喜欢
    • 2019-10-08
    • 2021-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多