Skip to content

Commit

Permalink
fix(ios): CAPWebView config update (#7004)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven0351 authored Oct 18, 2023
1 parent 280e404 commit f3e8be0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ios/Capacitor/Capacitor/CAPWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,29 @@ extension CAPWebView {
webViewConfiguration.suppressesIncrementalRendering = false
webViewConfiguration.allowsAirPlayForMediaPlayback = true
webViewConfiguration.mediaTypesRequiringUserActionForPlayback = []

if #available(iOS 14.0, *) {
webViewConfiguration.limitsNavigationsToAppBoundDomains = instanceConfiguration.limitsNavigationsToAppBoundDomains
}

if let appendUserAgent = instanceConfiguration.appendedUserAgentString {
if let appName = webViewConfiguration.applicationNameForUserAgent {
webViewConfiguration.applicationNameForUserAgent = "\(appName) \(appendUserAgent)"
} else {
webViewConfiguration.applicationNameForUserAgent = appendUserAgent
}
}

if let preferredContentMode = instanceConfiguration.preferredContentMode {
var mode = WKWebpagePreferences.ContentMode.recommended
if preferredContentMode == "mobile" {
mode = WKWebpagePreferences.ContentMode.mobile
} else if preferredContentMode == "desktop" {
mode = WKWebpagePreferences.ContentMode.desktop
}
webViewConfiguration.defaultWebpagePreferences.preferredContentMode = mode
}

return webViewConfiguration
}

Expand Down

0 comments on commit f3e8be0

Please sign in to comment.