8

I working on webview in flutter . I cant able to open http url in IOS. It working on https. Can anyone suggest how to overcome this.

I put in info.plist

 <key>io.flutter.embedded_views_preview</key>
    <string>YES</string>
     <key>NSAllowsArbitraryLoads</key>
    <true/>

Regards, Sathish

4 Answers 4

20

Add this to your Info.plist

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
    </dict>
Sign up to request clarification or add additional context in comments.

1 Comment

Is the use of NSAllowsArbitraryLoadsInWebContent required, and if so, why? In my case, NSAllowsArbitraryLoads was enough.
14

Apple Transport Security needs to be disabled.

  1. Open project in Xcode.
  2. Open Info.plist
  3. Add a new row to Information Property List (check id it's already there)

enter image description here

  1. Select App Transport Security Settings
  2. Make sure Allow Arbitrary Loads is set to YES

3 Comments

Thank you so much ilyas you saved time
Thanks, works. Info.plist: <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
2

In case if your url has some special character. You need to encode the URL like this,

WebView(
      initialUrl: Uri.encodeFull(EnterUrlHere),
      ...
 )

1 Comment

this worked for me, after wasting so much time
0

In iOS UIWebview is deprecated so your should your WKWebview.

For Flutter you should use below dependency :

webview_flutter: 0.3.15+1

Import this class :

import 'package:webview_flutter/webview_flutter.dart';

Add this widget :

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: new AppBar(
      title: Text(this.title,centerTitle: true
  ),
  body: WebView(
  initialUrl: url,
  onPageFinished:(value){
    setState(() {
      print("====your page is load");
    });
  },
  )
);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.