@capgo/inappbrowser 6.4.0-beta.1 → 6.4.3
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 +19 -13
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +25 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +21 -11
- package/dist/docs.json +8 -8
- package/dist/esm/definitions.d.ts +14 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +1 -1
- package/dist/esm/web.js +2 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +2 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.m +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +4 -3
- package/ios/Plugin/WKWebViewController.swift +3 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ Add the following to your `Info.plist` file:
|
|
|
74
74
|
* [`close()`](#close)
|
|
75
75
|
* [`openWebView(...)`](#openwebview)
|
|
76
76
|
* [`executeScript(...)`](#executescript)
|
|
77
|
-
* [`
|
|
77
|
+
* [`postMessage(...)`](#postmessage)
|
|
78
78
|
* [`setUrl(...)`](#seturl)
|
|
79
79
|
* [`addListener('urlChangeEvent', ...)`](#addlistenerurlchangeevent-)
|
|
80
80
|
* [`addListener('closeEvent', ...)`](#addlistenercloseevent-)
|
|
@@ -195,17 +195,19 @@ Injects JavaScript code into the InAppBrowser window.
|
|
|
195
195
|
--------------------
|
|
196
196
|
|
|
197
197
|
|
|
198
|
-
###
|
|
198
|
+
### postMessage(...)
|
|
199
199
|
|
|
200
200
|
```typescript
|
|
201
|
-
|
|
201
|
+
postMessage(options: { detail: Record<string, any>; }) => Promise<void>
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
-
Sends an event to the webview.
|
|
204
|
+
Sends an event to the webview. you can listen to this event with addListener("messageFromWebview", listenerFunc: (event: <a href="#record">Record</a><string, any>) => void)
|
|
205
|
+
detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects
|
|
206
|
+
Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.
|
|
205
207
|
|
|
206
|
-
| Param | Type
|
|
207
|
-
| ------------- |
|
|
208
|
-
| **`options`** | <code
|
|
208
|
+
| Param | Type |
|
|
209
|
+
| ------------- | ------------------------------------------------------------------------- |
|
|
210
|
+
| **`options`** | <code>{ detail: <a href="#record">Record</a><string, any>; }</code> |
|
|
209
211
|
|
|
210
212
|
--------------------
|
|
211
213
|
|
|
@@ -290,15 +292,19 @@ Will be triggered when user clicks on confirm button when disclaimer is required
|
|
|
290
292
|
### addListener('messageFromWebview', ...)
|
|
291
293
|
|
|
292
294
|
```typescript
|
|
293
|
-
addListener(eventName: "messageFromWebview", listenerFunc: (event: Record<string, any
|
|
295
|
+
addListener(eventName: "messageFromWebview", listenerFunc: (event: { detail: Record<string, any>; }) => void) => Promise<PluginListenerHandle>
|
|
294
296
|
```
|
|
295
297
|
|
|
296
|
-
Will be triggered when event is sent from webview
|
|
298
|
+
Will be triggered when event is sent from webview, to send an event to the webview use window.mobileApp.postMessage({ "detail": { "message": "myMessage" } })
|
|
299
|
+
detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects
|
|
300
|
+
Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.
|
|
297
301
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
|
301
|
-
|
|
|
302
|
+
This method is inject at runtime in the webview
|
|
303
|
+
|
|
304
|
+
| Param | Type |
|
|
305
|
+
| ------------------ | --------------------------------------------------------------------------------------------- |
|
|
306
|
+
| **`eventName`** | <code>'messageFromWebview'</code> |
|
|
307
|
+
| **`listenerFunc`** | <code>(event: { detail: <a href="#record">Record</a><string, any>; }) => void</code> |
|
|
302
308
|
|
|
303
309
|
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
304
310
|
|
|
@@ -452,6 +452,31 @@ public class InAppBrowserPlugin
|
|
|
452
452
|
);
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
+
@PluginMethod
|
|
456
|
+
public void postMessage(PluginCall call) {
|
|
457
|
+
if (webViewDialog == null) {
|
|
458
|
+
call.reject("WebView is not initialized");
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
JSObject eventData = call.getObject("detail");
|
|
462
|
+
// Log event data
|
|
463
|
+
Log.d("InAppBrowserPlugin", "Event data: " + eventData.toString());
|
|
464
|
+
if (eventData == null) {
|
|
465
|
+
call.reject("No event data provided");
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
this.getActivity()
|
|
469
|
+
.runOnUiThread(
|
|
470
|
+
new Runnable() {
|
|
471
|
+
@Override
|
|
472
|
+
public void run() {
|
|
473
|
+
webViewDialog.postMessageToJS(eventData);
|
|
474
|
+
call.resolve();
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
|
|
455
480
|
@PluginMethod
|
|
456
481
|
public void executeScript(PluginCall call) {
|
|
457
482
|
String script = call.getString("code");
|
|
@@ -38,6 +38,8 @@ import java.util.HashMap;
|
|
|
38
38
|
import java.util.Iterator;
|
|
39
39
|
import java.util.Map;
|
|
40
40
|
import java.util.Objects;
|
|
41
|
+
import org.json.JSONArray;
|
|
42
|
+
import org.json.JSONObject;
|
|
41
43
|
|
|
42
44
|
public class WebViewDialog extends Dialog {
|
|
43
45
|
|
|
@@ -211,24 +213,32 @@ public class WebViewDialog extends Dialog {
|
|
|
211
213
|
}
|
|
212
214
|
}
|
|
213
215
|
|
|
214
|
-
public void
|
|
216
|
+
public void postMessageToJS(Object detail) {
|
|
215
217
|
if (_webView != null) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
try {
|
|
219
|
+
JSONObject jsonObject = new JSONObject();
|
|
220
|
+
jsonObject.put("detail", detail);
|
|
221
|
+
String jsonDetail = jsonObject.toString();
|
|
222
|
+
String script =
|
|
223
|
+
"window.dispatchEvent(new CustomEvent('messageFromNative', " +
|
|
224
|
+
jsonDetail +
|
|
225
|
+
"));";
|
|
226
|
+
_webView.post(() -> _webView.evaluateJavascript(script, null));
|
|
227
|
+
} catch (Exception e) {
|
|
228
|
+
Log.e(
|
|
229
|
+
"postMessageToJS",
|
|
230
|
+
"Error sending message to JS: " + e.getMessage()
|
|
231
|
+
);
|
|
232
|
+
}
|
|
221
233
|
}
|
|
222
234
|
}
|
|
223
235
|
|
|
224
236
|
private void injectJavaScriptInterface() {
|
|
225
237
|
String script =
|
|
226
|
-
"if (!window.
|
|
227
|
-
" window.
|
|
238
|
+
"if (!window.mobileApp) { " +
|
|
239
|
+
" window.mobileApp = { " +
|
|
228
240
|
" postMessage: function(message) { " +
|
|
229
|
-
" if (window.
|
|
230
|
-
" window.webkit.messageHandlers.messageHandler.postMessage(message); " +
|
|
231
|
-
" } else if (window.AndroidInterface) { " +
|
|
241
|
+
" if (window.AndroidInterface) { " +
|
|
232
242
|
" window.AndroidInterface.postMessage(JSON.stringify(message)); " +
|
|
233
243
|
" } " +
|
|
234
244
|
" } " +
|
package/dist/docs.json
CHANGED
|
@@ -129,22 +129,22 @@
|
|
|
129
129
|
"slug": "executescript"
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
|
-
"name": "
|
|
133
|
-
"signature": "(options: Record<string, any
|
|
132
|
+
"name": "postMessage",
|
|
133
|
+
"signature": "(options: { detail: Record<string, any>; }) => Promise<void>",
|
|
134
134
|
"parameters": [
|
|
135
135
|
{
|
|
136
136
|
"name": "options",
|
|
137
137
|
"docs": "",
|
|
138
|
-
"type": "Record<string, any
|
|
138
|
+
"type": "{ detail: Record<string, any>; }"
|
|
139
139
|
}
|
|
140
140
|
],
|
|
141
141
|
"returns": "Promise<void>",
|
|
142
142
|
"tags": [],
|
|
143
|
-
"docs": "Sends an event to the webview.",
|
|
143
|
+
"docs": "Sends an event to the webview. you can listen to this event with addListener(\"messageFromWebview\", listenerFunc: (event: Record<string, any>) => void)\ndetail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\nYour object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.",
|
|
144
144
|
"complexTypes": [
|
|
145
145
|
"Record"
|
|
146
146
|
],
|
|
147
|
-
"slug": "
|
|
147
|
+
"slug": "postmessage"
|
|
148
148
|
},
|
|
149
149
|
{
|
|
150
150
|
"name": "setUrl",
|
|
@@ -251,7 +251,7 @@
|
|
|
251
251
|
},
|
|
252
252
|
{
|
|
253
253
|
"name": "addListener",
|
|
254
|
-
"signature": "(eventName: \"messageFromWebview\", listenerFunc: (event: Record<string, any
|
|
254
|
+
"signature": "(eventName: \"messageFromWebview\", listenerFunc: (event: { detail: Record<string, any>; }) => void) => Promise<PluginListenerHandle>",
|
|
255
255
|
"parameters": [
|
|
256
256
|
{
|
|
257
257
|
"name": "eventName",
|
|
@@ -261,12 +261,12 @@
|
|
|
261
261
|
{
|
|
262
262
|
"name": "listenerFunc",
|
|
263
263
|
"docs": "",
|
|
264
|
-
"type": "(event: Record<string, any
|
|
264
|
+
"type": "(event: { detail: Record<string, any>; }) => void"
|
|
265
265
|
}
|
|
266
266
|
],
|
|
267
267
|
"returns": "Promise<PluginListenerHandle>",
|
|
268
268
|
"tags": [],
|
|
269
|
-
"docs": "Will be triggered when event is sent from webview",
|
|
269
|
+
"docs": "Will be triggered when event is sent from webview, to send an event to the webview use window.mobileApp.postMessage({ \"detail\": { \"message\": \"myMessage\" } })\ndetail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\nYour object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n\nThis method is inject at runtime in the webview",
|
|
270
270
|
"complexTypes": [
|
|
271
271
|
"PluginListenerHandle",
|
|
272
272
|
"Record"
|
|
@@ -254,9 +254,13 @@ export interface InAppBrowserPlugin {
|
|
|
254
254
|
code: string;
|
|
255
255
|
}): Promise<void>;
|
|
256
256
|
/**
|
|
257
|
-
* Sends an event to the webview.
|
|
257
|
+
* Sends an event to the webview. you can listen to this event with addListener("messageFromWebview", listenerFunc: (event: Record<string, any>) => void)
|
|
258
|
+
* detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects
|
|
259
|
+
* Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.
|
|
258
260
|
*/
|
|
259
|
-
|
|
261
|
+
postMessage(options: {
|
|
262
|
+
detail: Record<string, any>;
|
|
263
|
+
}): Promise<void>;
|
|
260
264
|
/**
|
|
261
265
|
* Sets the URL of the webview.
|
|
262
266
|
*/
|
|
@@ -282,9 +286,15 @@ export interface InAppBrowserPlugin {
|
|
|
282
286
|
*/
|
|
283
287
|
addListener(eventName: "confirmBtnClicked", listenerFunc: ConfirmBtnListener): Promise<PluginListenerHandle>;
|
|
284
288
|
/**
|
|
285
|
-
* Will be triggered when event is sent from webview
|
|
289
|
+
* Will be triggered when event is sent from webview, to send an event to the webview use window.mobileApp.postMessage({ "detail": { "message": "myMessage" } })
|
|
290
|
+
* detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects
|
|
291
|
+
* Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.
|
|
292
|
+
*
|
|
293
|
+
* This method is inject at runtime in the webview
|
|
286
294
|
*/
|
|
287
|
-
addListener(eventName: "messageFromWebview", listenerFunc: (event:
|
|
295
|
+
addListener(eventName: "messageFromWebview", listenerFunc: (event: {
|
|
296
|
+
detail: Record<string, any>;
|
|
297
|
+
}) => void): Promise<PluginListenerHandle>;
|
|
288
298
|
/**
|
|
289
299
|
* Will be triggered when page is loaded
|
|
290
300
|
*/
|
|
@@ -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 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
|
|
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. you can listen to this event with addListener(\"messageFromWebview\", listenerFunc: (event: Record<string, any>) => void)\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n */\n postMessage(options: { detail: 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, to send an event to the webview use window.mobileApp.postMessage({ \"detail\": { \"message\": \"myMessage\" } })\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n *\n * This method is inject at runtime in the webview\n */\n addListener(\n eventName: \"messageFromWebview\",\n listenerFunc: (event: { detail: 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,5 +13,5 @@ export declare class InAppBrowserWeb extends WebPlugin implements InAppBrowserPl
|
|
|
13
13
|
url: string;
|
|
14
14
|
}): Promise<any>;
|
|
15
15
|
reload(): Promise<any>;
|
|
16
|
-
|
|
16
|
+
postMessage(options: Record<string, any>): Promise<any>;
|
|
17
17
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -32,8 +32,8 @@ export class InAppBrowserWeb extends WebPlugin {
|
|
|
32
32
|
console.log("reload");
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
async
|
|
36
|
-
console.log("
|
|
35
|
+
async postMessage(options) {
|
|
36
|
+
console.log("postMessage", options);
|
|
37
37
|
return options;
|
|
38
38
|
}
|
|
39
39
|
}
|
package/dist/esm/web.js.map
CHANGED
|
@@ -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;IACD,KAA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;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 postMessage(options: Record<string, any>): Promise<any> {\n console.log(\"postMessage\", options);\n return options;\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -52,8 +52,8 @@ class InAppBrowserWeb extends core.WebPlugin {
|
|
|
52
52
|
console.log("reload");
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
async
|
|
56
|
-
console.log("
|
|
55
|
+
async postMessage(options) {
|
|
56
|
+
console.log("postMessage", options);
|
|
57
57
|
return options;
|
|
58
58
|
}
|
|
59
59
|
}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -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 async
|
|
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 postMessage(options) {\n console.log(\"postMessage\", 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,CA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CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -51,8 +51,8 @@ var capacitorInAppBrowser = (function (exports, core) {
|
|
|
51
51
|
console.log("reload");
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
async
|
|
55
|
-
console.log("
|
|
54
|
+
async postMessage(options) {
|
|
55
|
+
console.log("postMessage", options);
|
|
56
56
|
return options;
|
|
57
57
|
}
|
|
58
58
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -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 async
|
|
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 postMessage(options) {\n console.log(\"postMessage\", 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,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AAa,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,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL;;;;;;;;;;;;;;;"}
|
|
@@ -14,6 +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(
|
|
17
|
+
CAP_PLUGIN_METHOD(postMessage, CAPPluginReturnPromise);
|
|
18
18
|
CAP_PLUGIN_METHOD(insertCSS, CAPPluginReturnPromise);
|
|
19
19
|
)
|
|
@@ -233,15 +233,16 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
233
233
|
call.resolve()
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
@objc func
|
|
237
|
-
let eventData = call.getObject("
|
|
236
|
+
@objc func postMessage(_ call: CAPPluginCall) {
|
|
237
|
+
let eventData = call.getObject("detail", [:])
|
|
238
238
|
// Check if eventData is empty
|
|
239
239
|
if eventData.isEmpty {
|
|
240
240
|
call.reject("Event data must not be empty")
|
|
241
241
|
return
|
|
242
242
|
}
|
|
243
|
+
print("Event data: \(eventData)")
|
|
243
244
|
|
|
244
|
-
self.webViewController?.
|
|
245
|
+
self.webViewController?.postMessageToJS(message: eventData)
|
|
245
246
|
call.resolve()
|
|
246
247
|
}
|
|
247
248
|
|
|
@@ -223,7 +223,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
// Method to send a message from Swift to JavaScript
|
|
226
|
-
open func
|
|
226
|
+
open func postMessageToJS(message: [String: Any]) {
|
|
227
227
|
if let jsonData = try? JSONSerialization.data(withJSONObject: message, options: []),
|
|
228
228
|
let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
229
229
|
let script = "window.dispatchEvent(new CustomEvent('messageFromNative', { detail: \(jsonString) }));"
|
|
@@ -246,13 +246,11 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
246
246
|
|
|
247
247
|
func injectJavaScriptInterface() {
|
|
248
248
|
let script = """
|
|
249
|
-
if (!window.
|
|
250
|
-
window.
|
|
249
|
+
if (!window.mobileApp) {
|
|
250
|
+
window.mobileApp = {
|
|
251
251
|
postMessage: function(message) {
|
|
252
252
|
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.messageHandler) {
|
|
253
253
|
window.webkit.messageHandlers.messageHandler.postMessage(message);
|
|
254
|
-
} else if (window.AndroidInterface) {
|
|
255
|
-
window.AndroidInterface.postMessage(JSON.stringify(message));
|
|
256
254
|
}
|
|
257
255
|
}
|
|
258
256
|
};
|
|
@@ -807,7 +805,6 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
807
805
|
self.url = u
|
|
808
806
|
delegate?.webViewController?(self, didStart: u)
|
|
809
807
|
}
|
|
810
|
-
self.injectJavaScriptInterface()
|
|
811
808
|
}
|
|
812
809
|
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
|
813
810
|
if !didpageInit && self.capBrowserPlugin?.isPresentAfterPageLoad == true {
|
|
@@ -831,7 +828,6 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
831
828
|
self.url = url
|
|
832
829
|
delegate?.webViewController?(self, didFail: url, withError: error)
|
|
833
830
|
}
|
|
834
|
-
self.injectJavaScriptInterface()
|
|
835
831
|
self.capBrowserPlugin?.notifyListeners("pageLoadError", data: [:])
|
|
836
832
|
}
|
|
837
833
|
|
|
@@ -842,7 +838,6 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
842
838
|
self.url = url
|
|
843
839
|
delegate?.webViewController?(self, didFail: url, withError: error)
|
|
844
840
|
}
|
|
845
|
-
self.injectJavaScriptInterface()
|
|
846
841
|
self.capBrowserPlugin?.notifyListeners("pageLoadError", data: [:])
|
|
847
842
|
}
|
|
848
843
|
|