flutter_webview_plugin icon indicating copy to clipboard operation
flutter_webview_plugin copied to clipboard

User Agent in ipad not detected

Open stephanievea opened this issue 4 years ago • 1 comments

WebviewScaffold( primary: false, resizeToAvoidBottomInset: !Platform.isIOS, userAgent: "SomeRandomUserAgent", url: "$someUrl", appBar: ab, initialChild: Container(), withLocalStorage: true, withJavascript: true, );

We have tested this in iphone ipad android simulators and devices and it works on iphone and android 
but not in ipad. 

what appears - in ipad - according to our logs is 
"Mozilla/5.9 (Mackintosh; Intel Mac OS X 10_15_4) AppleWebKit/605/1/15 (KHTML, like Gecko)"

Otherwise it "SomeRandomUserAgent"

stephanievea avatar May 05 '21 07:05 stephanievea

There is a fix described here:

In your project folder, edit the ./ios/.symlinks/plugins/flutter_webview_plugin/ios/Classes/FlutterWebviewPlugin.m file and after line 144 insert the following:

if (@available(iOS 9.0, *)) {
    if (userAgent != (id)[NSNull null]) {
        self.webview.customUserAgent = userAgent;
    }
}

Then do a flutter clean/pub get and it should resolve the issue.

ouija avatar Jun 02 '21 17:06 ouija