@capgo/inappbrowser 1.2.20 → 1.3.1
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/README.md +6 -3
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +4 -0
- package/dist/docs.json +32 -1
- package/dist/esm/definitions.d.ts +14 -1
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +14 -5
- package/ios/Plugin/WKWebViewController.swift +7 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -259,9 +259,10 @@ Reload the current web page.
|
|
|
259
259
|
|
|
260
260
|
#### ClearCookieOptions
|
|
261
261
|
|
|
262
|
-
| Prop
|
|
263
|
-
|
|
|
264
|
-
| **`url`**
|
|
262
|
+
| Prop | Type |
|
|
263
|
+
| ----------- | -------------------- |
|
|
264
|
+
| **`url`** | <code>string</code> |
|
|
265
|
+
| **`cache`** | <code>boolean</code> |
|
|
265
266
|
|
|
266
267
|
|
|
267
268
|
#### HttpCookie
|
|
@@ -293,6 +294,8 @@ Reload the current web page.
|
|
|
293
294
|
| **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
|
|
294
295
|
| **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser, only on IOS | <code>BackgroundColor.BLACK</code> | 0.1.0 |
|
|
295
296
|
| **`isPresentAfterPageLoad`** | <code>boolean</code> | Open url in a new window fullscreen isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | <code>false</code> | 0.1.0 |
|
|
297
|
+
| **`isInspectable`** | <code>boolean</code> | Whether the website in the webview is inspectable or not, ios only | <code>false</code> | |
|
|
298
|
+
| **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
|
|
296
299
|
| **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
|
|
297
300
|
| **`closeModal`** | <code>boolean</code> | CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately. | <code>false</code> | 1.1.0 |
|
|
298
301
|
| **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
|
|
@@ -188,6 +188,7 @@ public class InAppBrowserPlugin
|
|
|
188
188
|
@PluginMethod
|
|
189
189
|
public void clearCookies(PluginCall call) {
|
|
190
190
|
String url = call.getString("url");
|
|
191
|
+
Boolean clearCache = call.getBoolean("cache", false);
|
|
191
192
|
if (url == null || TextUtils.isEmpty(url)) {
|
|
192
193
|
call.reject("Invalid URL");
|
|
193
194
|
} else {
|
|
@@ -201,6 +202,9 @@ public class InAppBrowserPlugin
|
|
|
201
202
|
url,
|
|
202
203
|
cookieName + "=; Expires=Thu, 01 Jan 1970 00:00:01 GMT"
|
|
203
204
|
);
|
|
205
|
+
if (clearCache) {
|
|
206
|
+
cookieManager.removeSessionCookie();
|
|
207
|
+
}
|
|
204
208
|
}
|
|
205
209
|
}
|
|
206
210
|
call.resolve();
|
package/dist/docs.json
CHANGED
|
@@ -324,6 +324,13 @@
|
|
|
324
324
|
"docs": "",
|
|
325
325
|
"complexTypes": [],
|
|
326
326
|
"type": "string"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"name": "cache",
|
|
330
|
+
"tags": [],
|
|
331
|
+
"docs": "",
|
|
332
|
+
"complexTypes": [],
|
|
333
|
+
"type": "boolean | undefined"
|
|
327
334
|
}
|
|
328
335
|
]
|
|
329
336
|
},
|
|
@@ -471,7 +478,7 @@
|
|
|
471
478
|
],
|
|
472
479
|
"docs": "Title of the browser",
|
|
473
480
|
"complexTypes": [],
|
|
474
|
-
"type": "string"
|
|
481
|
+
"type": "string | undefined"
|
|
475
482
|
},
|
|
476
483
|
{
|
|
477
484
|
"name": "backgroundColor",
|
|
@@ -507,6 +514,30 @@
|
|
|
507
514
|
"complexTypes": [],
|
|
508
515
|
"type": "boolean | undefined"
|
|
509
516
|
},
|
|
517
|
+
{
|
|
518
|
+
"name": "isInspectable",
|
|
519
|
+
"tags": [
|
|
520
|
+
{
|
|
521
|
+
"text": "false",
|
|
522
|
+
"name": "default"
|
|
523
|
+
}
|
|
524
|
+
],
|
|
525
|
+
"docs": "Whether the website in the webview is inspectable or not, ios only",
|
|
526
|
+
"complexTypes": [],
|
|
527
|
+
"type": "boolean | undefined"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
"name": "isAnimated",
|
|
531
|
+
"tags": [
|
|
532
|
+
{
|
|
533
|
+
"text": "true",
|
|
534
|
+
"name": "default"
|
|
535
|
+
}
|
|
536
|
+
],
|
|
537
|
+
"docs": "Whether the webview opening is animated or not, ios only",
|
|
538
|
+
"complexTypes": [],
|
|
539
|
+
"type": "boolean | undefined"
|
|
540
|
+
},
|
|
510
541
|
{
|
|
511
542
|
"name": "showReloadButton",
|
|
512
543
|
"tags": [
|
|
@@ -36,6 +36,7 @@ export interface GetCookieOptions {
|
|
|
36
36
|
}
|
|
37
37
|
export interface ClearCookieOptions {
|
|
38
38
|
url: string;
|
|
39
|
+
cache?: boolean;
|
|
39
40
|
}
|
|
40
41
|
export interface OpenOptions {
|
|
41
42
|
/**
|
|
@@ -93,7 +94,7 @@ export interface OpenWebViewOptions {
|
|
|
93
94
|
* @since 0.1.0
|
|
94
95
|
* @default 'New Window'
|
|
95
96
|
*/
|
|
96
|
-
title
|
|
97
|
+
title?: string;
|
|
97
98
|
/**
|
|
98
99
|
* Background color of the browser, only on IOS
|
|
99
100
|
* @since 0.1.0
|
|
@@ -108,6 +109,18 @@ export interface OpenWebViewOptions {
|
|
|
108
109
|
* @default false
|
|
109
110
|
*/
|
|
110
111
|
isPresentAfterPageLoad?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Whether the website in the webview is inspectable or not, ios only
|
|
114
|
+
*
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
isInspectable?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Whether the webview opening is animated or not, ios only
|
|
120
|
+
*
|
|
121
|
+
* @default true
|
|
122
|
+
*/
|
|
123
|
+
isAnimated?: boolean;
|
|
111
124
|
/**
|
|
112
125
|
* Shows a reload button that reloads the web page
|
|
113
126
|
* @since 1.0.15
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n cache?: boolean;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title?: string;\n /**\n * Background color of the browser, only on IOS\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * Open url in a new window fullscreen\n *\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n *\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\n *\n * @default true\n */\n isAnimated?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n *\n * @since 1.1.0\n * @default false\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n *\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n *\n * @since 1.2.5\n * @default '#ffffff''\n */\n toolbarColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n *\n * @since 1.2.5\n * @default false\n */\n showArrow?: boolean;\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear cookies of url\n *\n * @since 0.5.0\n */\n clearCookies(options: ClearCookieOptions): Promise<any>;\n\n /**\n * Get cookies for a specific URL.\n * @param options The options, including the URL to get cookies for.\n * @returns A promise that resolves with the cookies.\n */\n getCookies(options: GetCookieOptions): Promise<Record<string, string>>;\n\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Reload the current web page.\n *\n * @since 1.0.0\n */\n reload(): Promise<any>; // Add this line\n}\n"]}
|
|
@@ -43,8 +43,8 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
43
43
|
#endif
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
func presentView() {
|
|
47
|
-
self.bridge?.viewController?.present(self.navigationWebViewController!, animated:
|
|
46
|
+
func presentView(isAnimated: Bool = true) {
|
|
47
|
+
self.bridge?.viewController?.present(self.navigationWebViewController!, animated: isAnimated, completion: {
|
|
48
48
|
self.currentPluginCall?.resolve()
|
|
49
49
|
})
|
|
50
50
|
}
|
|
@@ -52,6 +52,11 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
52
52
|
@objc func clearCookies(_ call: CAPPluginCall) {
|
|
53
53
|
let dataStore = WKWebsiteDataStore.default()
|
|
54
54
|
let urlString = call.getString("url") ?? ""
|
|
55
|
+
let clearCache = call.getBool("cache") ?? false
|
|
56
|
+
|
|
57
|
+
if clearCache {
|
|
58
|
+
URLCache.shared.removeAllCachedResponses()
|
|
59
|
+
}
|
|
55
60
|
|
|
56
61
|
guard let url = URL(string: urlString), let hostName = url.host else {
|
|
57
62
|
call.reject("Invalid URL")
|
|
@@ -113,6 +118,8 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
113
118
|
let closeModalDescription = call.getString("closeModalDescription", "Are you sure you want to close this window?")
|
|
114
119
|
let closeModalOk = call.getString("closeModalOk", "OK")
|
|
115
120
|
let closeModalCancel = call.getString("closeModalCancel", "Cancel")
|
|
121
|
+
let isInspectable = call.getBool("isInspectable", false)
|
|
122
|
+
let isAnimated = call.getBool("isAnimated", true)
|
|
116
123
|
|
|
117
124
|
var disclaimerContent = call.getObject("shareDisclaimer")
|
|
118
125
|
let toolbarType = call.getString("toolbarType", "")
|
|
@@ -128,7 +135,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
128
135
|
let url = URL(string: urlString)
|
|
129
136
|
|
|
130
137
|
if self.isPresentAfterPageLoad {
|
|
131
|
-
self.webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
138
|
+
self.webViewController = WKWebViewController.init(url: url!, headers: headers, isInspectable: isInspectable)
|
|
132
139
|
} else {
|
|
133
140
|
self.webViewController = WKWebViewController.init()
|
|
134
141
|
self.webViewController?.setHeaders(headers: headers)
|
|
@@ -169,7 +176,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
169
176
|
self.webViewController?.leftNavigaionBarItemTypes = toolbarItems + [.reload]
|
|
170
177
|
}
|
|
171
178
|
if !self.isPresentAfterPageLoad {
|
|
172
|
-
self.presentView()
|
|
179
|
+
self.presentView(isAnimated: isAnimated)
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
182
|
}
|
|
@@ -220,6 +227,8 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
220
227
|
self.setup()
|
|
221
228
|
}
|
|
222
229
|
|
|
230
|
+
let isInspectable = call.getBool("isInspectable", false)
|
|
231
|
+
|
|
223
232
|
self.currentPluginCall = call
|
|
224
233
|
|
|
225
234
|
guard let urlString = call.getString("url") else {
|
|
@@ -240,7 +249,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
240
249
|
let url = URL(string: urlString)
|
|
241
250
|
|
|
242
251
|
if self.isPresentAfterPageLoad {
|
|
243
|
-
self.webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
252
|
+
self.webViewController = WKWebViewController.init(url: url!, headers: headers, isInspectable: isInspectable)
|
|
244
253
|
} else {
|
|
245
254
|
self.webViewController = WKWebViewController.init()
|
|
246
255
|
self.webViewController?.setHeaders(headers: headers)
|
|
@@ -60,11 +60,11 @@ open class WKWebViewController: UIViewController {
|
|
|
60
60
|
self.initWebview()
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
public init(url: URL, headers: [String: String]) {
|
|
63
|
+
public init(url: URL, headers: [String: String], isInspectable: Bool) {
|
|
64
64
|
super.init(nibName: nil, bundle: nil)
|
|
65
65
|
self.source = .remote(url)
|
|
66
66
|
self.setHeaders(headers: headers)
|
|
67
|
-
self.initWebview()
|
|
67
|
+
self.initWebview(isInspectable: isInspectable)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
open var hasDynamicTitle = false
|
|
@@ -206,7 +206,7 @@ open class WKWebViewController: UIViewController {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
open func initWebview() {
|
|
209
|
+
open func initWebview(isInspectable: Bool = true) {
|
|
210
210
|
|
|
211
211
|
self.view.backgroundColor = UIColor.white
|
|
212
212
|
|
|
@@ -216,6 +216,10 @@ open class WKWebViewController: UIViewController {
|
|
|
216
216
|
let webConfiguration = WKWebViewConfiguration()
|
|
217
217
|
let webView = WKWebView(frame: .zero, configuration: webConfiguration)
|
|
218
218
|
|
|
219
|
+
if #available(iOS 16.4, *) {
|
|
220
|
+
webView.isInspectable = isInspectable
|
|
221
|
+
}
|
|
222
|
+
|
|
219
223
|
webView.uiDelegate = self
|
|
220
224
|
webView.navigationDelegate = self
|
|
221
225
|
|