@capgo/inappbrowser 6.3.3 → 6.4.0-beta.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 CHANGED
@@ -74,10 +74,14 @@ Add the following to your `Info.plist` file:
74
74
  * [`close()`](#close)
75
75
  * [`openWebView(...)`](#openwebview)
76
76
  * [`executeScript(...)`](#executescript)
77
+ * [`sendEventToWebView(...)`](#sendeventtowebview)
77
78
  * [`setUrl(...)`](#seturl)
78
79
  * [`addListener('urlChangeEvent', ...)`](#addlistenerurlchangeevent-)
79
80
  * [`addListener('closeEvent', ...)`](#addlistenercloseevent-)
80
81
  * [`addListener('confirmBtnClicked', ...)`](#addlistenerconfirmbtnclicked-)
82
+ * [`addListener('messageFromWebview', ...)`](#addlistenermessagefromwebview-)
83
+ * [`addListener('browserPageLoaded', ...)`](#addlistenerbrowserpageloaded-)
84
+ * [`addListener('pageLoadError', ...)`](#addlistenerpageloaderror-)
81
85
  * [`removeAllListeners()`](#removealllisteners)
82
86
  * [`reload()`](#reload)
83
87
  * [Interfaces](#interfaces)
@@ -150,6 +154,8 @@ Get cookies for a specific URL.
150
154
  close() => Promise<any>
151
155
  ```
152
156
 
157
+ Close the webview.
158
+
153
159
  **Returns:** <code>Promise&lt;any&gt;</code>
154
160
 
155
161
  --------------------
@@ -189,12 +195,29 @@ Injects JavaScript code into the InAppBrowser window.
189
195
  --------------------
190
196
 
191
197
 
198
+ ### sendEventToWebView(...)
199
+
200
+ ```typescript
201
+ sendEventToWebView(options: Record<string, any>) => Promise<void>
202
+ ```
203
+
204
+ Sends an event to the webview.
205
+
206
+ | Param | Type |
207
+ | ------------- | ------------------------------------------------------------ |
208
+ | **`options`** | <code><a href="#record">Record</a>&lt;string, any&gt;</code> |
209
+
210
+ --------------------
211
+
212
+
192
213
  ### setUrl(...)
193
214
 
194
215
  ```typescript
195
216
  setUrl(options: { url: string; }) => Promise<any>
196
217
  ```
197
218
 
219
+ Sets the URL of the webview.
220
+
198
221
  | Param | Type |
199
222
  | ------------- | ----------------------------- |
200
223
  | **`options`** | <code>{ url: string; }</code> |
@@ -264,6 +287,60 @@ Will be triggered when user clicks on confirm button when disclaimer is required
264
287
  --------------------
265
288
 
266
289
 
290
+ ### addListener('messageFromWebview', ...)
291
+
292
+ ```typescript
293
+ addListener(eventName: "messageFromWebview", listenerFunc: (event: Record<string, any>) => void) => Promise<PluginListenerHandle>
294
+ ```
295
+
296
+ Will be triggered when event is sent from webview
297
+
298
+ | Param | Type |
299
+ | ------------------ | -------------------------------------------------------------------------------- |
300
+ | **`eventName`** | <code>'messageFromWebview'</code> |
301
+ | **`listenerFunc`** | <code>(event: <a href="#record">Record</a>&lt;string, any&gt;) =&gt; void</code> |
302
+
303
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
304
+
305
+ --------------------
306
+
307
+
308
+ ### addListener('browserPageLoaded', ...)
309
+
310
+ ```typescript
311
+ addListener(eventName: "browserPageLoaded", listenerFunc: () => void) => Promise<PluginListenerHandle>
312
+ ```
313
+
314
+ Will be triggered when page is loaded
315
+
316
+ | Param | Type |
317
+ | ------------------ | -------------------------------- |
318
+ | **`eventName`** | <code>'browserPageLoaded'</code> |
319
+ | **`listenerFunc`** | <code>() =&gt; void</code> |
320
+
321
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
322
+
323
+ --------------------
324
+
325
+
326
+ ### addListener('pageLoadError', ...)
327
+
328
+ ```typescript
329
+ addListener(eventName: "pageLoadError", listenerFunc: () => void) => Promise<PluginListenerHandle>
330
+ ```
331
+
332
+ Will be triggered when page is loaded
333
+
334
+ | Param | Type |
335
+ | ------------------ | ---------------------------- |
336
+ | **`eventName`** | <code>'pageLoadError'</code> |
337
+ | **`listenerFunc`** | <code>() =&gt; void</code> |
338
+
339
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
340
+
341
+ --------------------
342
+
343
+
267
344
  ### removeAllListeners()
268
345
 
269
346
  ```typescript
@@ -22,11 +22,12 @@ import com.getcapacitor.PermissionState;
22
22
  import com.getcapacitor.Plugin;
23
23
  import com.getcapacitor.PluginCall;
24
24
  import com.getcapacitor.PluginMethod;
25
- import com.getcapacitor.annotation.ActivityCallback;
26
25
  import com.getcapacitor.annotation.CapacitorPlugin;
27
26
  import com.getcapacitor.annotation.Permission;
28
27
  import com.getcapacitor.annotation.PermissionCallback;
29
28
  import java.util.Iterator;
29
+ import org.json.JSONException;
30
+ import org.json.JSONObject;
30
31
 
31
32
  @CapacitorPlugin(
32
33
  name = "InAppBrowser",
@@ -394,6 +395,43 @@ public class InAppBrowserPlugin
394
395
  public void pageLoadError() {
395
396
  notifyListeners("pageLoadError", new JSObject());
396
397
  }
398
+
399
+ @Override
400
+ public void javascriptCallback(String message) {
401
+ // Handle the message received from JavaScript
402
+ Log.d(
403
+ "WebViewDialog",
404
+ "Received message from JavaScript: " + message
405
+ );
406
+ // Process the message as needed
407
+ try {
408
+ // Parse the received message as a JSON object
409
+ JSONObject jsonMessage = new JSONObject(message);
410
+
411
+ // Create a new JSObject to send to the Capacitor plugin
412
+ JSObject jsObject = new JSObject();
413
+
414
+ // Iterate through the keys in the JSON object and add them to the JSObject
415
+ Iterator<String> keys = jsonMessage.keys();
416
+ while (keys.hasNext()) {
417
+ String key = keys.next();
418
+ jsObject.put(key, jsonMessage.get(key));
419
+ }
420
+
421
+ // Notify listeners with the parsed message
422
+ notifyListeners("messageFromWebview", jsObject);
423
+ } catch (JSONException e) {
424
+ Log.e(
425
+ "WebViewDialog",
426
+ "Error parsing JSON message: " + e.getMessage()
427
+ );
428
+
429
+ // If JSON parsing fails, send the raw message as a string
430
+ JSObject jsObject = new JSObject();
431
+ jsObject.put("rawMessage", message);
432
+ notifyListeners("messageFromWebview", jsObject);
433
+ }
434
+ }
397
435
  }
398
436
  );
399
437
  this.getActivity()
@@ -8,4 +8,6 @@ public interface WebViewCallbacks {
8
8
  public void pageLoaded();
9
9
 
10
10
  public void pageLoadError();
11
+
12
+ public void javascriptCallback(String message);
11
13
  }
@@ -18,6 +18,7 @@ import android.view.View;
18
18
  import android.view.Window;
19
19
  import android.view.WindowManager;
20
20
  import android.webkit.HttpAuthHandler;
21
+ import android.webkit.JavascriptInterface;
21
22
  import android.webkit.PermissionRequest;
22
23
  import android.webkit.SslErrorHandler;
23
24
  import android.webkit.ValueCallback;
@@ -73,6 +74,15 @@ public class WebViewDialog extends Dialog {
73
74
  this.isInitialized = false;
74
75
  }
75
76
 
77
+ public class JavaScriptInterface {
78
+
79
+ @JavascriptInterface
80
+ public void postMessage(String message) {
81
+ // Handle message from JavaScript
82
+ _options.getCallbacks().javascriptCallback(message);
83
+ }
84
+ }
85
+
76
86
  public void presentWebView() {
77
87
  requestWindowFeature(Window.FEATURE_NO_TITLE);
78
88
  setCancelable(true);
@@ -89,7 +99,10 @@ public class WebViewDialog extends Dialog {
89
99
  );
90
100
 
91
101
  this._webView = findViewById(R.id.browser_view);
92
-
102
+ _webView.addJavascriptInterface(
103
+ new JavaScriptInterface(),
104
+ "AndroidInterface"
105
+ );
93
106
  _webView.getSettings().setJavaScriptEnabled(true);
94
107
  _webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
95
108
  _webView.getSettings().setDatabaseEnabled(true);
@@ -198,6 +211,32 @@ public class WebViewDialog extends Dialog {
198
211
  }
199
212
  }
200
213
 
214
+ public void sendMessageToJS(String message) {
215
+ if (_webView != null) {
216
+ String script =
217
+ "window.dispatchEvent(new CustomEvent('messageFromNative', { detail: " +
218
+ message +
219
+ " }));";
220
+ _webView.post(() -> _webView.evaluateJavascript(script, null));
221
+ }
222
+ }
223
+
224
+ private void injectJavaScriptInterface() {
225
+ String script =
226
+ "if (!window.webview) { " +
227
+ " window.webview = { " +
228
+ " postMessage: function(message) { " +
229
+ " if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.messageHandler) { " +
230
+ " window.webkit.messageHandlers.messageHandler.postMessage(message); " +
231
+ " } else if (window.AndroidInterface) { " +
232
+ " window.AndroidInterface.postMessage(JSON.stringify(message)); " +
233
+ " } " +
234
+ " } " +
235
+ " }; " +
236
+ "}";
237
+ _webView.evaluateJavascript(script, null);
238
+ }
239
+
201
240
  private void openFileChooser(
202
241
  ValueCallback<Uri[]> filePathCallback,
203
242
  String acceptType
@@ -486,12 +525,12 @@ public class WebViewDialog extends Dialog {
486
525
  _options.getCallbacks().urlChangeEvent(url);
487
526
  }
488
527
  super.doUpdateVisitedHistory(view, url, isReload);
528
+ injectJavaScriptInterface();
489
529
  }
490
530
 
491
531
  @Override
492
532
  public void onPageFinished(WebView view, String url) {
493
533
  super.onPageFinished(view, url);
494
- _options.getCallbacks().pageLoaded();
495
534
  if (!isInitialized) {
496
535
  isInitialized = true;
497
536
  _webView.clearHistory();
@@ -520,6 +559,7 @@ public class WebViewDialog extends Dialog {
520
559
  }
521
560
 
522
561
  _options.getCallbacks().pageLoaded();
562
+ injectJavaScriptInterface();
523
563
  }
524
564
 
525
565
  @Override
package/dist/docs.json CHANGED
@@ -85,7 +85,7 @@
85
85
  "parameters": [],
86
86
  "returns": "Promise<any>",
87
87
  "tags": [],
88
- "docs": "",
88
+ "docs": "Close the webview.",
89
89
  "complexTypes": [],
90
90
  "slug": "close"
91
91
  },
@@ -128,6 +128,24 @@
128
128
  "complexTypes": [],
129
129
  "slug": "executescript"
130
130
  },
131
+ {
132
+ "name": "sendEventToWebView",
133
+ "signature": "(options: Record<string, any>) => Promise<void>",
134
+ "parameters": [
135
+ {
136
+ "name": "options",
137
+ "docs": "",
138
+ "type": "Record<string, any>"
139
+ }
140
+ ],
141
+ "returns": "Promise<void>",
142
+ "tags": [],
143
+ "docs": "Sends an event to the webview.",
144
+ "complexTypes": [
145
+ "Record"
146
+ ],
147
+ "slug": "sendeventtowebview"
148
+ },
131
149
  {
132
150
  "name": "setUrl",
133
151
  "signature": "(options: { url: string; }) => Promise<any>",
@@ -140,7 +158,7 @@
140
158
  ],
141
159
  "returns": "Promise<any>",
142
160
  "tags": [],
143
- "docs": "",
161
+ "docs": "Sets the URL of the webview.",
144
162
  "complexTypes": [],
145
163
  "slug": "seturl"
146
164
  },
@@ -231,6 +249,76 @@
231
249
  ],
232
250
  "slug": "addlistenerconfirmbtnclicked-"
233
251
  },
252
+ {
253
+ "name": "addListener",
254
+ "signature": "(eventName: \"messageFromWebview\", listenerFunc: (event: Record<string, any>) => void) => Promise<PluginListenerHandle>",
255
+ "parameters": [
256
+ {
257
+ "name": "eventName",
258
+ "docs": "",
259
+ "type": "'messageFromWebview'"
260
+ },
261
+ {
262
+ "name": "listenerFunc",
263
+ "docs": "",
264
+ "type": "(event: Record<string, any>) => void"
265
+ }
266
+ ],
267
+ "returns": "Promise<PluginListenerHandle>",
268
+ "tags": [],
269
+ "docs": "Will be triggered when event is sent from webview",
270
+ "complexTypes": [
271
+ "PluginListenerHandle",
272
+ "Record"
273
+ ],
274
+ "slug": "addlistenermessagefromwebview-"
275
+ },
276
+ {
277
+ "name": "addListener",
278
+ "signature": "(eventName: \"browserPageLoaded\", listenerFunc: () => void) => Promise<PluginListenerHandle>",
279
+ "parameters": [
280
+ {
281
+ "name": "eventName",
282
+ "docs": "",
283
+ "type": "'browserPageLoaded'"
284
+ },
285
+ {
286
+ "name": "listenerFunc",
287
+ "docs": "",
288
+ "type": "() => void"
289
+ }
290
+ ],
291
+ "returns": "Promise<PluginListenerHandle>",
292
+ "tags": [],
293
+ "docs": "Will be triggered when page is loaded",
294
+ "complexTypes": [
295
+ "PluginListenerHandle"
296
+ ],
297
+ "slug": "addlistenerbrowserpageloaded-"
298
+ },
299
+ {
300
+ "name": "addListener",
301
+ "signature": "(eventName: \"pageLoadError\", listenerFunc: () => void) => Promise<PluginListenerHandle>",
302
+ "parameters": [
303
+ {
304
+ "name": "eventName",
305
+ "docs": "",
306
+ "type": "'pageLoadError'"
307
+ },
308
+ {
309
+ "name": "listenerFunc",
310
+ "docs": "",
311
+ "type": "() => void"
312
+ }
313
+ ],
314
+ "returns": "Promise<PluginListenerHandle>",
315
+ "tags": [],
316
+ "docs": "Will be triggered when page is loaded",
317
+ "complexTypes": [
318
+ "PluginListenerHandle"
319
+ ],
320
+ "slug": "addlistenerpageloaderror-"
321
+ },
234
322
  {
235
323
  "name": "removeAllListeners",
236
324
  "signature": "() => Promise<void>",
@@ -237,6 +237,9 @@ export interface InAppBrowserPlugin {
237
237
  * @returns A promise that resolves with the cookies.
238
238
  */
239
239
  getCookies(options: GetCookieOptions): Promise<Record<string, string>>;
240
+ /**
241
+ * Close the webview.
242
+ */
240
243
  close(): Promise<any>;
241
244
  /**
242
245
  * Open url in a new webview with toolbars
@@ -250,6 +253,13 @@ export interface InAppBrowserPlugin {
250
253
  executeScript({ code }: {
251
254
  code: string;
252
255
  }): Promise<void>;
256
+ /**
257
+ * Sends an event to the webview.
258
+ */
259
+ sendEventToWebView(options: Record<string, any>): Promise<void>;
260
+ /**
261
+ * Sets the URL of the webview.
262
+ */
253
263
  setUrl(options: {
254
264
  url: string;
255
265
  }): Promise<any>;
@@ -271,6 +281,18 @@ export interface InAppBrowserPlugin {
271
281
  * @since 0.0.1
272
282
  */
273
283
  addListener(eventName: "confirmBtnClicked", listenerFunc: ConfirmBtnListener): Promise<PluginListenerHandle>;
284
+ /**
285
+ * Will be triggered when event is sent from webview
286
+ */
287
+ addListener(eventName: "messageFromWebview", listenerFunc: (event: Record<string, any>) => void): Promise<PluginListenerHandle>;
288
+ /**
289
+ * Will be triggered when page is loaded
290
+ */
291
+ addListener(eventName: "browserPageLoaded", listenerFunc: () => void): Promise<PluginListenerHandle>;
292
+ /**
293
+ * Will be triggered when page is loaded
294
+ */
295
+ addListener(eventName: "pageLoadError", listenerFunc: () => void): Promise<PluginListenerHandle>;
274
296
  /**
275
297
  * Remove all listeners for this plugin.
276
298
  *
@@ -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 cache?: boolean;\n}\n\nexport interface Credentials {\n username: string;\n password: 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 * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\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 * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\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 * If true, active the native navigation within the webview, Android only\n *\n * @default false\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * usefull to force user to stay on the webview, Android only\n *\n * @default false\n */\n disableGoBackOnNativeApplication?: boolean;\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 * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\n *\n * @since 6.1.0\n * @default false\n */\n ignoreUntrustedSSLError?: 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 /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\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>;\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>;\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>;\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"]}
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 Credentials {\n username: string;\n password: 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 * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\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 * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\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 * If true, active the native navigation within the webview, Android only\n *\n * @default false\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * usefull to force user to stay on the webview, Android only\n *\n * @default false\n */\n disableGoBackOnNativeApplication?: boolean;\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 * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\n *\n * @since 6.1.0\n * @default false\n */\n ignoreUntrustedSSLError?: 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 the webview.\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 /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n /**\n * Sends an event to the webview.\n */\n sendEventToWebView(options: Record<string, any>): Promise<void>;\n /**\n * Sets the URL of the webview.\n */\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>;\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>;\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>;\n /**\n * Will be triggered when event is sent from webview\n */\n addListener(\n eventName: \"messageFromWebview\",\n listenerFunc: (event: Record<string, any>) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page is loaded\n */\n addListener(\n eventName: \"browserPageLoaded\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page is loaded\n */\n addListener(\n eventName: \"pageLoadError\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\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"]}
package/dist/esm/web.d.ts CHANGED
@@ -13,4 +13,5 @@ export declare class InAppBrowserWeb extends WebPlugin implements InAppBrowserPl
13
13
  url: string;
14
14
  }): Promise<any>;
15
15
  reload(): Promise<any>;
16
+ sendEventToWebView(options: Record<string, any>): Promise<any>;
16
17
  }
package/dist/esm/web.js CHANGED
@@ -32,5 +32,9 @@ export class InAppBrowserWeb extends WebPlugin {
32
32
  console.log("reload");
33
33
  return;
34
34
  }
35
+ async sendEventToWebView(options) {
36
+ console.log("sendEventToWebView", options);
37
+ return options;
38
+ }
35
39
  }
36
40
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAA2B;QAC5C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAyB;QACxC,oCAAoC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAoB;QAC5C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAwB;QACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,MAAM;QACV,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO;IACT,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n InAppBrowserPlugin,\n OpenWebViewOptions,\n OpenOptions,\n GetCookieOptions,\n ClearCookieOptions,\n} from \"./definitions\";\n\nexport class InAppBrowserWeb extends WebPlugin implements InAppBrowserPlugin {\n async open(options: OpenOptions): Promise<any> {\n console.log(\"open\", options);\n return options;\n }\n\n async clearCookies(options: ClearCookieOptions): Promise<any> {\n console.log(\"cleanCookies\", options);\n return;\n }\n\n async getCookies(options: GetCookieOptions): Promise<any> {\n // Web implementation to get cookies\n return options;\n }\n\n async openWebView(options: OpenWebViewOptions): Promise<any> {\n console.log(\"openWebView\", options);\n return options;\n }\n\n async executeScript({ code }: { code: string }): Promise<any> {\n console.log(\"code\", code);\n return code;\n }\n\n async close(): Promise<any> {\n console.log(\"close\");\n return;\n }\n\n async setUrl(options: { url: string }): Promise<any> {\n console.log(\"setUrl\", options.url);\n return;\n }\n\n async reload(): Promise<any> {\n console.log(\"reload\");\n return;\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAA2B;QAC5C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAyB;QACxC,oCAAoC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAoB;QAC5C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAwB;QACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,MAAM;QACV,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO;IACT,CAAC;IACD,KAAK,CAAC,kBAAkB,CAAC,OAA4B;QACnD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC3C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n InAppBrowserPlugin,\n OpenWebViewOptions,\n OpenOptions,\n GetCookieOptions,\n ClearCookieOptions,\n} from \"./definitions\";\n\nexport class InAppBrowserWeb extends WebPlugin implements InAppBrowserPlugin {\n async open(options: OpenOptions): Promise<any> {\n console.log(\"open\", options);\n return options;\n }\n\n async clearCookies(options: ClearCookieOptions): Promise<any> {\n console.log(\"cleanCookies\", options);\n return;\n }\n\n async getCookies(options: GetCookieOptions): Promise<any> {\n // Web implementation to get cookies\n return options;\n }\n\n async openWebView(options: OpenWebViewOptions): Promise<any> {\n console.log(\"openWebView\", options);\n return options;\n }\n\n async executeScript({ code }: { code: string }): Promise<any> {\n console.log(\"code\", code);\n return code;\n }\n\n async close(): Promise<any> {\n console.log(\"close\");\n return;\n }\n\n async setUrl(options: { url: string }): Promise<any> {\n console.log(\"setUrl\", options.url);\n return;\n }\n\n async reload(): Promise<any> {\n console.log(\"reload\");\n return;\n }\n async sendEventToWebView(options: Record<string, any>): Promise<any> {\n console.log(\"sendEventToWebView\", options);\n return options;\n }\n}\n"]}
@@ -52,6 +52,10 @@ class InAppBrowserWeb extends core.WebPlugin {
52
52
  console.log("reload");
53
53
  return;
54
54
  }
55
+ async sendEventToWebView(options) {
56
+ console.log("sendEventToWebView", options);
57
+ return options;
58
+ }
55
59
  }
56
60
 
57
61
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst InAppBrowser = registerPlugin(\"InAppBrowser\", {\n web: () => import(\"./web\").then((m) => new m.InAppBrowserWeb()),\n});\nexport * from \"./definitions\";\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log(\"open\", options);\n return options;\n }\n async clearCookies(options) {\n console.log(\"cleanCookies\", options);\n return;\n }\n async getCookies(options) {\n // Web implementation to get cookies\n return options;\n }\n async openWebView(options) {\n console.log(\"openWebView\", options);\n return options;\n }\n async executeScript({ code }) {\n console.log(\"code\", code);\n return code;\n }\n async close() {\n console.log(\"close\");\n return;\n }\n async setUrl(options) {\n console.log(\"setUrl\", options.url);\n return;\n }\n async reload() {\n console.log(\"reload\");\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA,iCAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,6BAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;AAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACVhC,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,YAAY,CAAC,OAAO,EAAE;AAChC,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAC7C,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;AAC9B;AACA,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE;AAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAClC,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAC3C,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst InAppBrowser = registerPlugin(\"InAppBrowser\", {\n web: () => import(\"./web\").then((m) => new m.InAppBrowserWeb()),\n});\nexport * from \"./definitions\";\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log(\"open\", options);\n return options;\n }\n async clearCookies(options) {\n console.log(\"cleanCookies\", options);\n return;\n }\n async getCookies(options) {\n // Web implementation to get cookies\n return options;\n }\n async openWebView(options) {\n console.log(\"openWebView\", options);\n return options;\n }\n async executeScript({ code }) {\n console.log(\"code\", code);\n return code;\n }\n async close() {\n console.log(\"close\");\n return;\n }\n async setUrl(options) {\n console.log(\"setUrl\", options.url);\n return;\n }\n async reload() {\n console.log(\"reload\");\n return;\n }\n async sendEventToWebView(options) {\n console.log(\"sendEventToWebView\", options);\n return options;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA,iCAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,6BAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;AAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACVhC,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,YAAY,CAAC,OAAO,EAAE;AAChC,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAC7C,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;AAC9B;AACA,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE;AAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAClC,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAC3C,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;AACtC,QAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;AACnD,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -51,6 +51,10 @@ var capacitorInAppBrowser = (function (exports, core) {
51
51
  console.log("reload");
52
52
  return;
53
53
  }
54
+ async sendEventToWebView(options) {
55
+ console.log("sendEventToWebView", options);
56
+ return options;
57
+ }
54
58
  }
55
59
 
56
60
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst InAppBrowser = registerPlugin(\"InAppBrowser\", {\n web: () => import(\"./web\").then((m) => new m.InAppBrowserWeb()),\n});\nexport * from \"./definitions\";\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log(\"open\", options);\n return options;\n }\n async clearCookies(options) {\n console.log(\"cleanCookies\", options);\n return;\n }\n async getCookies(options) {\n // Web implementation to get cookies\n return options;\n }\n async openWebView(options) {\n console.log(\"openWebView\", options);\n return options;\n }\n async executeScript({ code }) {\n console.log(\"code\", code);\n return code;\n }\n async close() {\n console.log(\"close\");\n return;\n }\n async setUrl(options) {\n console.log(\"setUrl\", options.url);\n return;\n }\n async reload() {\n console.log(\"reload\");\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,qCAAgB;IAC3B,CAAC,UAAU,eAAe,EAAE;IAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,iCAAY;IACvB,CAAC,UAAU,WAAW,EAAE;IACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACVhC,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,YAAY,CAAC,OAAO,EAAE;IAChC,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC7C,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;IAC9B;IACA,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE;IAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClC,QAAQ,OAAO,IAAI,CAAC;IACpB,KAAK;IACL,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,MAAM,GAAG;IACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst InAppBrowser = registerPlugin(\"InAppBrowser\", {\n web: () => import(\"./web\").then((m) => new m.InAppBrowserWeb()),\n});\nexport * from \"./definitions\";\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log(\"open\", options);\n return options;\n }\n async clearCookies(options) {\n console.log(\"cleanCookies\", options);\n return;\n }\n async getCookies(options) {\n // Web implementation to get cookies\n return options;\n }\n async openWebView(options) {\n console.log(\"openWebView\", options);\n return options;\n }\n async executeScript({ code }) {\n console.log(\"code\", code);\n return code;\n }\n async close() {\n console.log(\"close\");\n return;\n }\n async setUrl(options) {\n console.log(\"setUrl\", options.url);\n return;\n }\n async reload() {\n console.log(\"reload\");\n return;\n }\n async sendEventToWebView(options) {\n console.log(\"sendEventToWebView\", options);\n return options;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,qCAAgB;IAC3B,CAAC,UAAU,eAAe,EAAE;IAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,iCAAY;IACvB,CAAC,UAAU,WAAW,EAAE;IACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACVhC,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,YAAY,CAAC,OAAO,EAAE;IAChC,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC7C,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;IAC9B;IACA,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE;IAClC,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClC,QAAQ,OAAO,IAAI,CAAC;IACpB,KAAK;IACL,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,MAAM,GAAG;IACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;IACtC,QAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;IACnD,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL;;;;;;;;;;;;;;;"}
@@ -14,5 +14,6 @@ CAP_PLUGIN(InAppBrowserPlugin, "InAppBrowser",
14
14
  CAP_PLUGIN_METHOD(close, CAPPluginReturnPromise);
15
15
  CAP_PLUGIN_METHOD(hide, CAPPluginReturnPromise);
16
16
  CAP_PLUGIN_METHOD(executeScript, CAPPluginReturnPromise);
17
+ CAP_PLUGIN_METHOD(sendEventToWebView, CAPPluginReturnPromise);
17
18
  CAP_PLUGIN_METHOD(insertCSS, CAPPluginReturnPromise);
18
19
  )
@@ -189,6 +189,7 @@ public class InAppBrowserPlugin: CAPPlugin {
189
189
  if !self.isPresentAfterPageLoad {
190
190
  self.presentView(isAnimated: isAnimated)
191
191
  }
192
+ call.resolve()
192
193
  }
193
194
  }
194
195
 
@@ -229,6 +230,19 @@ public class InAppBrowserPlugin: CAPPlugin {
229
230
  return
230
231
  }
231
232
  self.webViewController?.executeScript(script: script)
233
+ call.resolve()
234
+ }
235
+
236
+ @objc func sendEventToWebView(_ call: CAPPluginCall) {
237
+ let eventData = call.getObject("eventData", [:])
238
+ // Check if eventData is empty
239
+ if eventData.isEmpty {
240
+ call.reject("Event data must not be empty")
241
+ return
242
+ }
243
+
244
+ self.webViewController?.sendMessageToJS(message: eventData)
245
+ call.resolve()
232
246
  }
233
247
 
234
248
  func isHexColorCode(_ input: String) -> Bool {
@@ -304,6 +318,7 @@ public class InAppBrowserPlugin: CAPPlugin {
304
318
  if !self.isPresentAfterPageLoad {
305
319
  self.presentView()
306
320
  }
321
+ call.resolve()
307
322
  }
308
323
  }
309
324
 
@@ -43,7 +43,7 @@ extension Dictionary {
43
43
  }
44
44
  }
45
45
 
46
- open class WKWebViewController: UIViewController {
46
+ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
47
47
 
48
48
  public init() {
49
49
  super.init(nibName: nil, bundle: nil)
@@ -222,6 +222,45 @@ open class WKWebViewController: UIViewController {
222
222
  self.credentials = credentials
223
223
  }
224
224
 
225
+ // Method to send a message from Swift to JavaScript
226
+ open func sendMessageToJS(message: [String: Any]) {
227
+ if let jsonData = try? JSONSerialization.data(withJSONObject: message, options: []),
228
+ let jsonString = String(data: jsonData, encoding: .utf8) {
229
+ let script = "window.dispatchEvent(new CustomEvent('messageFromNative', { detail: \(jsonString) }));"
230
+ webView?.evaluateJavaScript(script, completionHandler: nil)
231
+ }
232
+ }
233
+
234
+ // Method to receive messages from JavaScript
235
+ public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
236
+ if message.name == "messageHandler" {
237
+ if let messageBody = message.body as? [String: Any] {
238
+ print("Received message from JavaScript:", messageBody)
239
+ self.capBrowserPlugin?.notifyListeners("messageFromWebview", data: messageBody)
240
+ } else {
241
+ print("Received non-dictionary message from JavaScript:", message.body)
242
+ self.capBrowserPlugin?.notifyListeners("messageFromWebview", data: ["rawMessage": String(describing: message.body)])
243
+ }
244
+ }
245
+ }
246
+
247
+ func injectJavaScriptInterface() {
248
+ let script = """
249
+ if (!window.webview) {
250
+ window.webview = {
251
+ postMessage: function(message) {
252
+ if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.messageHandler) {
253
+ window.webkit.messageHandlers.messageHandler.postMessage(message);
254
+ } else if (window.AndroidInterface) {
255
+ window.AndroidInterface.postMessage(JSON.stringify(message));
256
+ }
257
+ }
258
+ };
259
+ }
260
+ """
261
+ webView?.evaluateJavaScript(script, completionHandler: nil)
262
+ }
263
+
225
264
  open func initWebview(isInspectable: Bool = true) {
226
265
 
227
266
  self.view.backgroundColor = UIColor.white
@@ -230,6 +269,9 @@ open class WKWebViewController: UIViewController {
230
269
  self.edgesForExtendedLayout = [.bottom]
231
270
 
232
271
  let webConfiguration = WKWebViewConfiguration()
272
+ let userContentController = WKUserContentController()
273
+ userContentController.add(self, name: "messageHandler")
274
+ webConfiguration.userContentController = userContentController
233
275
  let webView = WKWebView(frame: .zero, configuration: webConfiguration)
234
276
 
235
277
  if webView.responds(to: Selector(("setInspectable:"))) {
@@ -358,6 +400,7 @@ open class WKWebViewController: UIViewController {
358
400
  }
359
401
  case "URL":
360
402
  self.capBrowserPlugin?.notifyListeners("urlChangeEvent", data: ["url": webView?.url?.absoluteString ?? ""])
403
+ self.injectJavaScriptInterface()
361
404
  default:
362
405
  super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
363
406
  }
@@ -400,7 +443,9 @@ public extension WKWebViewController {
400
443
  }
401
444
 
402
445
  func executeScript(script: String, completion: ((Any?, Error?) -> Void)? = nil) {
403
- webView?.evaluateJavaScript(script, completionHandler: completion)
446
+ DispatchQueue.main.async { [weak self] in
447
+ self?.webView?.evaluateJavaScript(script, completionHandler: completion)
448
+ }
404
449
  }
405
450
  }
406
451
 
@@ -762,6 +807,7 @@ extension WKWebViewController: WKNavigationDelegate {
762
807
  self.url = u
763
808
  delegate?.webViewController?(self, didStart: u)
764
809
  }
810
+ self.injectJavaScriptInterface()
765
811
  }
766
812
  public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
767
813
  if !didpageInit && self.capBrowserPlugin?.isPresentAfterPageLoad == true {
@@ -774,6 +820,8 @@ extension WKWebViewController: WKNavigationDelegate {
774
820
  self.url = url
775
821
  delegate?.webViewController?(self, didFinish: url)
776
822
  }
823
+ self.injectJavaScriptInterface()
824
+ self.capBrowserPlugin?.notifyListeners("browserPageLoaded", data: [:])
777
825
  }
778
826
 
779
827
  public func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
@@ -783,6 +831,8 @@ extension WKWebViewController: WKNavigationDelegate {
783
831
  self.url = url
784
832
  delegate?.webViewController?(self, didFail: url, withError: error)
785
833
  }
834
+ self.injectJavaScriptInterface()
835
+ self.capBrowserPlugin?.notifyListeners("pageLoadError", data: [:])
786
836
  }
787
837
 
788
838
  public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
@@ -792,6 +842,8 @@ extension WKWebViewController: WKNavigationDelegate {
792
842
  self.url = url
793
843
  delegate?.webViewController?(self, didFail: url, withError: error)
794
844
  }
845
+ self.injectJavaScriptInterface()
846
+ self.capBrowserPlugin?.notifyListeners("pageLoadError", data: [:])
795
847
  }
796
848
 
797
849
  public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
@@ -817,8 +869,8 @@ extension WKWebViewController: WKNavigationDelegate {
817
869
  }
818
870
  let credential = URLCredential(trust: serverTrust)
819
871
  completionHandler(.useCredential, credential)
820
-
821
872
  }
873
+ self.injectJavaScriptInterface()
822
874
  }
823
875
 
824
876
  public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
@@ -851,6 +903,7 @@ extension WKWebViewController: WKNavigationDelegate {
851
903
  if let navigationType = NavigationType(rawValue: navigationAction.navigationType.rawValue), let result = delegate?.webViewController?(self, decidePolicy: u, navigationType: navigationType) {
852
904
  actionPolicy = result ? .allow : .cancel
853
905
  }
906
+ self.injectJavaScriptInterface()
854
907
  }
855
908
  }
856
909
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "6.3.3",
3
+ "version": "6.4.0-beta.1",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",