Skip to content

Commit

Permalink
Merge pull request openedx#246 from edx/custom_user_agent_for_webview
Browse files Browse the repository at this point in the history
Add custom user agent to hide app banner on web page
  • Loading branch information
rnr authored Jan 25, 2024
2 parents fe14ca8 + fbbfff6 commit e4ace45
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Core/Core/View/Base/Webview/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ public struct WebView: UIViewRepresentable {
Coordinator(self)
}

private var userAgent: String {
let info = Bundle.main.infoDictionary
return [
info?[kCFBundleExecutableKey as String],
info?[kCFBundleIdentifierKey as String],
info?["CFBundleShortVersionString"]
]
.compactMap { $0 as? String ?? "" }
.joined(separator: "/")
}

public func makeUIView(context: UIViewRepresentableContext<WebView>) -> WKWebView {
let webViewConfig = WKWebViewConfiguration()

Expand Down Expand Up @@ -219,6 +230,8 @@ public struct WebView: UIViewRepresentable {
}
}

webView.customUserAgent = userAgent

return webView
}

Expand Down

0 comments on commit e4ace45

Please sign in to comment.