@@ -77,24 +77,29 @@ class ViewController: UIViewController {
7777
7878 // settings
7979 webView. allowsBackForwardNavigationGestures = true
80- webView. configuration. ignoresViewportScaleLimits = false
8180 webView. configuration. preferences. javaScriptEnabled = true
82- // user agent
83- if ( useCustomUserAgent) {
84- webView. customUserAgent = customUserAgent
81+ if #available( iOS 10 . 0 , * ) {
82+ webView. configuration. ignoresViewportScaleLimits = false
8583 }
86- if ( useUserAgentPostfix) {
84+ // user agent
85+ if #available( iOS 9 . 0 , * ) {
8786 if ( useCustomUserAgent) {
88- webView. customUserAgent = customUserAgent + " " + userAgentPostfix
89- } else {
90- webView. evaluateJavaScript ( " navigator.userAgent " , completionHandler: { ( result, error) in
91- if let resultObject = result {
92- self . webView. customUserAgent = ( String ( describing: resultObject) + " " + userAgentPostfix)
93- }
94- } )
87+ webView. customUserAgent = customUserAgent
9588 }
89+ if ( useUserAgentPostfix) {
90+ if ( useCustomUserAgent) {
91+ webView. customUserAgent = customUserAgent + " " + userAgentPostfix
92+ } else {
93+ webView. evaluateJavaScript ( " navigator.userAgent " , completionHandler: { ( result, error) in
94+ if let resultObject = result {
95+ self . webView. customUserAgent = ( String ( describing: resultObject) + " " + userAgentPostfix)
96+ }
97+ } )
98+ }
99+ }
100+ webView. configuration. applicationNameForUserAgent = " "
96101 }
97- webView . configuration . applicationNameForUserAgent = " "
102+
98103
99104 // init observers
100105 webView. addObserver ( self , forKeyPath: #keyPath( WKWebView . isLoading) , options: NSKeyValueObservingOptions . new, context: nil )
@@ -121,7 +126,9 @@ class ViewController: UIViewController {
121126 // setup navigation
122127 navigationItem. title = appTitle
123128 if ( forceLargeTitle) {
124- navigationItem. largeTitleDisplayMode = UINavigationItem . LargeTitleDisplayMode. always
129+ if #available( iOS 11 . 0 , * ) {
130+ navigationItem. largeTitleDisplayMode = UINavigationItem . LargeTitleDisplayMode. always
131+ }
125132 }
126133 if ( useLightStatusBarStyle) {
127134 self . navigationController? . navigationBar. barStyle = UIBarStyle . black
@@ -191,7 +198,12 @@ extension ViewController: WKUIDelegate {
191198 } else {
192199 decisionHandler ( . cancel)
193200 if ( UIApplication . shared. canOpenURL ( requestUrl) ) {
194- UIApplication . shared. open ( requestUrl)
201+ if #available( iOS 10 . 0 , * ) {
202+ UIApplication . shared. open ( requestUrl)
203+ } else {
204+ // Fallback on earlier versions
205+ UIApplication . shared. openURL ( requestUrl)
206+ }
195207 }
196208 }
197209 } else {
0 commit comments