Skip to content

Commit 4c0d393

Browse files
committed
added support for ios9, prepared supporting ios8
1 parent b3f378d commit 4c0d393

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

ios-pwa-wrapper.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,15 @@
436436
isa = XCBuildConfiguration;
437437
buildSettings = {
438438
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
439+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
439440
CODE_SIGN_STYLE = Automatic;
440441
DEVELOPMENT_TEAM = 86W9Q5SP7G;
441442
INFOPLIST_FILE = "ios-pwa-wrapper/Info.plist";
443+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
442444
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
443445
PRODUCT_BUNDLE_IDENTIFIER = "at.xtools.ios-pwa-wrapper";
444446
PRODUCT_NAME = "$(TARGET_NAME)";
447+
PROVISIONING_PROFILE_SPECIFIER = "";
445448
SWIFT_VERSION = 4.0;
446449
TARGETED_DEVICE_FAMILY = "1,2";
447450
};
@@ -451,12 +454,15 @@
451454
isa = XCBuildConfiguration;
452455
buildSettings = {
453456
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
457+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
454458
CODE_SIGN_STYLE = Automatic;
455459
DEVELOPMENT_TEAM = 86W9Q5SP7G;
456460
INFOPLIST_FILE = "ios-pwa-wrapper/Info.plist";
461+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
457462
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
458463
PRODUCT_BUNDLE_IDENTIFIER = "at.xtools.ios-pwa-wrapper";
459464
PRODUCT_NAME = "$(TARGET_NAME)";
465+
PROVISIONING_PROFILE_SPECIFIER = "";
460466
SWIFT_VERSION = 4.0;
461467
TARGETED_DEVICE_FAMILY = "1,2";
462468
};

ios-pwa-wrapper/AppDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2121
// Change Navigation style
2222
UINavigationBar.appearance().barTintColor = navigationBarColor
2323
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: navigationTitleColor]
24-
UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: navigationTitleColor]
2524
UIBarButtonItem.appearance().tintColor = navigationButtonColor
25+
if #available(iOS 11.0, *) {
26+
UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: navigationTitleColor]
27+
}
2628

2729
return true
2830
}

ios-pwa-wrapper/ViewController.swift

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)