This is an automated email from the ASF dual-hosted git repository. niklasmerz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
The following commit(s) were added to refs/heads/master by this push: new 46c080f (ios): allow to set "preferredContentMode" (#688) 46c080f is described below commit 46c080f59a011747ba1b70f462b27fee26957247 Author: Niklas Merz <niklasm...@apache.org> AuthorDate: Sun Sep 20 01:48:32 2020 +0200 (ios): allow to set "preferredContentMode" (#688) PreferredContentMode can now be set with preference config. Since iPadOS came out iPads get a desktop Safari useragent by default. see #687 Co-authored-by: Tim Brust <git...@timbrust.de> --- README.md | 10 ++++++++++ src/ios/CDVWKInAppBrowser.m | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 2f19a7b..5e33249 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,16 @@ At the moment the only supported target in OSX is `_system`. `_blank` and `_self` targets are not yet implemented and are ignored silently. Pull requests and patches to get these to work are greatly appreciated. +### iOS Quirks + +Since the introduction of iPadOS 13, iPads try to adapt their content mode / user agent for the optimal browsing experience. This may result in iPads having their user agent set to Macintosh, making it hard to detect them as mobile devices using user agent string sniffing. You can change this with the `PreferredContentMode` preference in `config.xml`. + +```xml +<preference name="PreferredContentMode" value="mobile" /> +``` + +The example above forces the user agent to contain `iPad`. The other option is to use the value `desktop` to turn the user agent to `Macintosh`. + ### Browser Quirks - Plugin is implemented via iframe, diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index 903ada2..1935984 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -757,6 +757,15 @@ BOOL isExiting = FALSE; configuration.mediaPlaybackRequiresUserAction = _browserOptions.mediaplaybackrequiresuseraction; } + if (@available(iOS 13.0, *)) { + NSString *contentMode = [self settingForKey:@"PreferredContentMode"]; + if ([contentMode isEqual: @"mobile"]) { + configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile; + } else if ([contentMode isEqual: @"desktop"]) { + configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeDesktop; + } + + } self.webView = [[WKWebView alloc] initWithFrame:webViewBounds configuration:configuration]; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org