@capacitor/ios 8.0.0-alpha.3 → 8.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Capacitor/Capacitor/CAPBridgeViewController.swift +7 -13
- package/Capacitor/Capacitor/CAPNotifications.swift +4 -0
- package/Capacitor/Capacitor/CAPPlugin.h +5 -0
- package/Capacitor/Capacitor/CAPPlugin.m +5 -0
- package/Capacitor/Capacitor/CapacitorBridge.swift +1 -1
- package/Capacitor/Capacitor/Plugins/SystemBars.swift +133 -0
- package/Capacitor/Capacitor/WebViewDelegationHandler.swift +20 -0
- package/Capacitor/Capacitor/assets/native-bridge.js +1 -1
- package/package.json +3 -3
|
@@ -27,19 +27,7 @@ import Cordova
|
|
|
27
27
|
return false
|
|
28
28
|
}()
|
|
29
29
|
|
|
30
|
-
// TODO: Remove in Capacitor 8 after moving status bar plugin extensions code
|
|
31
|
-
@objc func handleViewDidAppear() {
|
|
32
|
-
if bridge?.config.hasInitialFocus ?? true {
|
|
33
|
-
self.webView?.becomeFirstResponder()
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
deinit {
|
|
38
|
-
NotificationCenter.default.removeObserver(self)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
30
|
override public final func loadView() {
|
|
42
|
-
NotificationCenter.default.addObserver(self, selector: #selector(self.handleViewDidAppear), name: Notification.Name(rawValue: "CapacitorViewDidAppear"), object: nil)
|
|
43
31
|
// load the configuration and set the logging flag
|
|
44
32
|
let configDescriptor = instanceDescriptor()
|
|
45
33
|
let configuration = InstanceConfiguration(with: configDescriptor, isDebug: CapacitorBridge.isDevEnvironment)
|
|
@@ -76,11 +64,17 @@ import Cordova
|
|
|
76
64
|
|
|
77
65
|
override open func viewDidAppear(_ animated: Bool) {
|
|
78
66
|
super.viewDidAppear(animated)
|
|
67
|
+
NotificationCenter.default.post(Notification(name: .capacitorViewDidAppear))
|
|
79
68
|
if bridge?.config.hasInitialFocus ?? true {
|
|
80
69
|
self.webView?.becomeFirstResponder()
|
|
81
70
|
}
|
|
82
71
|
}
|
|
83
72
|
|
|
73
|
+
override open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
74
|
+
super.viewWillTransition(to: size, with: coordinator)
|
|
75
|
+
NotificationCenter.default.post(Notification(name: .capacitorViewWillTransition))
|
|
76
|
+
}
|
|
77
|
+
|
|
84
78
|
override open func canPerformUnwindSegueAction(_ action: Selector, from fromViewController: UIViewController, withSender sender: Any) -> Bool {
|
|
85
79
|
return false
|
|
86
80
|
}
|
|
@@ -135,7 +129,7 @@ import Cordova
|
|
|
135
129
|
}
|
|
136
130
|
if let appendUserAgent = instanceConfiguration.appendedUserAgentString {
|
|
137
131
|
if let appName = webViewConfiguration.applicationNameForUserAgent {
|
|
138
|
-
webViewConfiguration.applicationNameForUserAgent = "\(appName)
|
|
132
|
+
webViewConfiguration.applicationNameForUserAgent = "\(appName) \(appendUserAgent)"
|
|
139
133
|
} else {
|
|
140
134
|
webViewConfiguration.applicationNameForUserAgent = appendUserAgent
|
|
141
135
|
}
|
|
@@ -16,6 +16,8 @@ extension Notification.Name {
|
|
|
16
16
|
public static let capacitorDecidePolicyForNavigationAction =
|
|
17
17
|
Notification.Name(rawValue: "CapacitorDecidePolicyForNavigationActionNotification")
|
|
18
18
|
public static let capacitorStatusBarTapped = Notification.Name(rawValue: "CapacitorStatusBarTappedNotification")
|
|
19
|
+
public static let capacitorViewDidAppear = Notification.Name(rawValue: "CapacitorViewDidAppear")
|
|
20
|
+
public static let capacitorViewWillTransition = Notification.Name(rawValue: "CapacitorViewWillTransition")
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
@objc extension NSNotification {
|
|
@@ -26,6 +28,8 @@ extension Notification.Name {
|
|
|
26
28
|
public static let capacitorDidFailToRegisterForRemoteNotifications = Notification.Name.capacitorDidFailToRegisterForRemoteNotifications
|
|
27
29
|
public static let capacitorDecidePolicyForNavigationAction = Notification.Name.capacitorDecidePolicyForNavigationAction
|
|
28
30
|
public static let capacitorStatusBarTapped = Notification.Name.capacitorStatusBarTapped
|
|
31
|
+
public static let capacitorViewDidAppear = Notification.Name.capacitorViewDidAppear
|
|
32
|
+
public static let capacitorViewWillTransition = Notification.Name.capacitorViewWillTransition
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
/**
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
* Returning nil will defer to the default Capacitor policy
|
|
39
39
|
*/
|
|
40
40
|
- (NSNumber* _Nullable)shouldOverrideLoad:(WKNavigationAction* _Nonnull)navigationAction;
|
|
41
|
+
/**
|
|
42
|
+
* Allows plugins to hook into and respond to the WebView's URL authentication challenge.
|
|
43
|
+
* Returning false will defer to the default response of [.rejectProtectionSpace](https://developer.apple.com/documentation/Foundation/URLSession/AuthChallengeDisposition/rejectProtectionSpace).
|
|
44
|
+
*/
|
|
45
|
+
- (BOOL)handleWKWebViewURLAuthenticationChallenge:(NSURLAuthenticationChallenge* _Nonnull)challenge completionHandler:(void (^_Nonnull)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler;
|
|
41
46
|
|
|
42
47
|
// Called after init if the plugin wants to do
|
|
43
48
|
// some loading so the plugin author doesn't
|
|
@@ -171,5 +171,10 @@
|
|
|
171
171
|
return nil;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
- (BOOL)handleWKWebViewURLAuthenticationChallenge:(NSURLAuthenticationChallenge* _Nonnull)challenge completionHandler:(void (^_Nonnull)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler {
|
|
175
|
+
return NO;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
174
179
|
@end
|
|
175
180
|
|
|
@@ -302,7 +302,7 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
|
|
|
302
302
|
Register all plugins that have been declared
|
|
303
303
|
*/
|
|
304
304
|
func registerPlugins() {
|
|
305
|
-
var pluginList: [AnyClass] = [CAPHttpPlugin.self, CAPConsolePlugin.self, CAPWebViewPlugin.self, CAPCookiesPlugin.self]
|
|
305
|
+
var pluginList: [AnyClass] = [CAPHttpPlugin.self, CAPConsolePlugin.self, CAPWebViewPlugin.self, CAPCookiesPlugin.self, CAPSystemBarsPlugin.self]
|
|
306
306
|
|
|
307
307
|
if autoRegisterPlugins {
|
|
308
308
|
do {
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc(CAPSystemBarsPlugin)
|
|
4
|
+
public class CAPSystemBarsPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
5
|
+
public let identifier = "CAPSystemBarsPlugin"
|
|
6
|
+
public let jsName = "SystemBars"
|
|
7
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
8
|
+
CAPPluginMethod(name: "setStyle", returnType: CAPPluginReturnPromise),
|
|
9
|
+
CAPPluginMethod(name: "setAnimation", returnType: CAPPluginReturnPromise),
|
|
10
|
+
CAPPluginMethod(name: "show", returnType: CAPPluginReturnPromise),
|
|
11
|
+
CAPPluginMethod(name: "hide", returnType: CAPPluginReturnPromise)
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
public private(set) var hideHomeIndicator: Bool = false
|
|
15
|
+
|
|
16
|
+
enum Style: String {
|
|
17
|
+
case dark = "DARK"
|
|
18
|
+
case light = "LIGHT"
|
|
19
|
+
case defaultStyle = "DEFAULT"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@objc override public func load() {
|
|
23
|
+
let hidden = getConfig().getBoolean("hidden", false)
|
|
24
|
+
|
|
25
|
+
if let style = getConfig().getString("style", "DEFAULT") {
|
|
26
|
+
setStyle(style: style)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if let animation = getConfig().getString("animation") {
|
|
30
|
+
setAnimation(animation: animation)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setHidden(hidden: hidden)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@objc func setStyle(_ call: CAPPluginCall) {
|
|
37
|
+
setStyle(style: call.getString("style") ?? Style.defaultStyle.rawValue)
|
|
38
|
+
call.resolve()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@objc func show(_ call: CAPPluginCall) {
|
|
42
|
+
let bar = call.getString("bar")
|
|
43
|
+
|
|
44
|
+
if let animation = call.getString("animation") {
|
|
45
|
+
setAnimation(animation: animation)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
DispatchQueue.main.async {
|
|
49
|
+
self.setHidden(hidden: false, bar: bar)
|
|
50
|
+
call.resolve()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@objc func hide(_ call: CAPPluginCall) {
|
|
55
|
+
let bar = call.getString("bar")
|
|
56
|
+
|
|
57
|
+
if let animation = call.getString("animation") {
|
|
58
|
+
setAnimation(animation: animation)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
DispatchQueue.main.async {
|
|
62
|
+
self.setHidden(hidden: true, bar: bar)
|
|
63
|
+
call.resolve()
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@objc func setAnimation(_ call: CAPPluginCall) {
|
|
68
|
+
let animation = call.getString("animation", "FADE")
|
|
69
|
+
setAnimation(animation: animation)
|
|
70
|
+
|
|
71
|
+
call.resolve()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
func setStyle(style: String) {
|
|
75
|
+
var newStyle: UIStatusBarStyle = .default
|
|
76
|
+
|
|
77
|
+
if let style = Style(rawValue: style.uppercased()) {
|
|
78
|
+
switch style {
|
|
79
|
+
case .dark:
|
|
80
|
+
newStyle = .lightContent
|
|
81
|
+
case .light:
|
|
82
|
+
newStyle = .darkContent
|
|
83
|
+
case .defaultStyle:
|
|
84
|
+
newStyle = .default
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
bridge?.statusBarStyle = newStyle
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
func setHidden(hidden: Bool, bar: String? = nil) {
|
|
92
|
+
if hidden {
|
|
93
|
+
if bar == nil || bar?.isEmpty ?? true || bar == "StatusBar" {
|
|
94
|
+
bridge?.statusBarVisible = false
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if bar == nil || bar?.isEmpty ?? true || bar == "NavigationBar" {
|
|
98
|
+
hideHomeIndicator = true
|
|
99
|
+
bridge?.viewController?.setNeedsUpdateOfHomeIndicatorAutoHidden()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if bar == nil || bar?.isEmpty ?? true || bar == "StatusBar" {
|
|
106
|
+
bridge?.statusBarVisible = true
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if bar == nil || bar?.isEmpty ?? true || bar == "NavigationBar" {
|
|
110
|
+
hideHomeIndicator = false
|
|
111
|
+
bridge?.viewController?.setNeedsUpdateOfHomeIndicatorAutoHidden()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
func setAnimation(animation: String) {
|
|
117
|
+
if animation.uppercased() == "NONE" {
|
|
118
|
+
bridge?.statusBarAnimation = .none
|
|
119
|
+
} else {
|
|
120
|
+
bridge?.statusBarAnimation = .fade
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
extension CAPBridgeViewController {
|
|
126
|
+
override public var prefersHomeIndicatorAutoHidden: Bool {
|
|
127
|
+
if let systemBarPlugin = self.bridge?.plugin(withName: "SystemBars") as? CAPSystemBarsPlugin {
|
|
128
|
+
return systemBarPlugin.hideHomeIndicator
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return false
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -161,6 +161,26 @@ open class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDelegat
|
|
|
161
161
|
webView.reload()
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
open func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping @MainActor (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
|
165
|
+
guard let bridge = bridge else {
|
|
166
|
+
completionHandler(.rejectProtectionSpace, nil)
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
for pluginObject in bridge.plugins {
|
|
171
|
+
let plugin = pluginObject.value
|
|
172
|
+
let selector = NSSelectorFromString("handleWKWebViewURLAuthenticationChallenge:completionHandler:")
|
|
173
|
+
if plugin.responds(to: selector) {
|
|
174
|
+
if plugin.handleWKWebViewURLAuthenticationChallenge(challenge, completionHandler: completionHandler) {
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
completionHandler(.rejectProtectionSpace, nil)
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
164
184
|
// MARK: - WKScriptMessageHandler
|
|
165
185
|
|
|
166
186
|
open func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/ios",
|
|
3
|
-
"version": "8.0.0-
|
|
3
|
+
"version": "8.0.0-beta.0",
|
|
4
4
|
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
|
|
5
5
|
"homepage": "https://capacitorjs.com",
|
|
6
6
|
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"verify": "npm run xc:build:Capacitor && npm run xc:build:CapacitorCordova",
|
|
24
|
-
"xc:build:Capacitor": "cd Capacitor && xcodebuild clean test -workspace Capacitor.xcworkspace -scheme Capacitor -destination 'platform=iOS Simulator,name=iPhone 16,OS=26.0' && cd ..",
|
|
24
|
+
"xc:build:Capacitor": "cd Capacitor && xcodebuild clean test -workspace Capacitor.xcworkspace -scheme Capacitor -destination 'platform=iOS Simulator,name=iPhone 16,OS=26.0.1' && cd ..",
|
|
25
25
|
"xc:build:CapacitorCordova": "cd CapacitorCordova && xcodebuild && cd .."
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@capacitor/core": "^8.0.0-
|
|
28
|
+
"@capacitor/core": "^8.0.0-beta.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|