@capgo/inappbrowser 8.0.0 → 8.0.2

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.
Files changed (50) hide show
  1. package/CapgoInappbrowser.podspec +2 -2
  2. package/LICENSE +373 -21
  3. package/Package.swift +28 -0
  4. package/README.md +600 -74
  5. package/android/build.gradle +17 -16
  6. package/android/src/main/AndroidManifest.xml +14 -2
  7. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +952 -204
  8. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +478 -81
  9. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewCallbacks.java +10 -4
  10. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +3021 -226
  11. package/android/src/main/res/drawable/ic_refresh.xml +9 -0
  12. package/android/src/main/res/drawable/ic_share.xml +10 -0
  13. package/android/src/main/res/layout/activity_browser.xml +10 -0
  14. package/android/src/main/res/layout/content_browser.xml +3 -2
  15. package/android/src/main/res/layout/tool_bar.xml +44 -7
  16. package/android/src/main/res/values/strings.xml +4 -0
  17. package/android/src/main/res/values/themes.xml +27 -0
  18. package/android/src/main/res/xml/file_paths.xml +14 -0
  19. package/dist/docs.json +1289 -149
  20. package/dist/esm/definitions.d.ts +614 -25
  21. package/dist/esm/definitions.js +17 -1
  22. package/dist/esm/definitions.js.map +1 -1
  23. package/dist/esm/index.d.ts +2 -2
  24. package/dist/esm/index.js +4 -4
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/web.d.ts +16 -3
  27. package/dist/esm/web.js +43 -7
  28. package/dist/esm/web.js.map +1 -1
  29. package/dist/plugin.cjs.js +60 -8
  30. package/dist/plugin.cjs.js.map +1 -1
  31. package/dist/plugin.js +60 -8
  32. package/dist/plugin.js.map +1 -1
  33. package/ios/{Plugin → Sources/InAppBrowserPlugin}/Enums.swift +5 -5
  34. package/ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift +954 -0
  35. package/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift +2003 -0
  36. package/package.json +32 -30
  37. package/ios/Plugin/Assets.xcassets/Back.imageset/Back.png +0 -0
  38. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@2x.png +0 -0
  39. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@3x.png +0 -0
  40. package/ios/Plugin/Assets.xcassets/Back.imageset/Contents.json +0 -26
  41. package/ios/Plugin/Assets.xcassets/Contents.json +0 -6
  42. package/ios/Plugin/Assets.xcassets/Forward.imageset/Contents.json +0 -26
  43. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward.png +0 -0
  44. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@2x.png +0 -0
  45. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@3x.png +0 -0
  46. package/ios/Plugin/InAppBrowserPlugin.h +0 -10
  47. package/ios/Plugin/InAppBrowserPlugin.m +0 -17
  48. package/ios/Plugin/InAppBrowserPlugin.swift +0 -203
  49. package/ios/Plugin/Info.plist +0 -24
  50. package/ios/Plugin/WKWebViewController.swift +0 -784
package/README.md CHANGED
@@ -1,9 +1,30 @@
1
1
  # @capgo/inappbrowser
2
- <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
- <div align="center">
4
- <h2><a href="https://capgo.app/">Check out: Capgo — Instant updates for capacitor</a></h2>
2
+ <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
+
4
+ <div align="center">
5
+ <h2><a href="https://capgo.app/?ref=plugin_inappbrowser"> ➡️ Get Instant updates for your App with Capgo</a></h2>
6
+ <h2><a href="https://capgo.app/consulting/?ref=plugin_inappbrowser"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
5
7
  </div>
6
- Capacitor plugin in app browser with urlChangeEvent
8
+
9
+ Capacitor plugin in app browser with urlChangeEvent, two way communication, camera and microphone usage, etc.
10
+
11
+ ## Why InAppBrowser?
12
+
13
+ The official Capacitor Browser plugin has strict security limitations that prevent advanced features. InAppBrowser removes these restrictions, enabling:
14
+
15
+ - **Two-way communication** between your app and the browser
16
+ - **JavaScript injection** for dynamic content manipulation
17
+ - **Camera and microphone access** within the browser context
18
+ - **URL change monitoring** for navigation tracking
19
+ - **Custom toolbars and UI** for branded experiences
20
+ - **Cookie and cache management** for session control
21
+ - **Custom sizes** for extra control of the display position
22
+
23
+ Perfect for OAuth flows, embedded web apps, video calls, and any scenario requiring deep integration with web content.
24
+
25
+ ## Documentation
26
+
27
+ The most complete doc is available here: https://capgo.app/docs/plugins/inappbrowser/
7
28
 
8
29
  ## Install
9
30
 
@@ -16,22 +37,188 @@ npx cap sync
16
37
  ```js
17
38
  import { InAppBrowser } from '@capgo/inappbrowser'
18
39
 
19
- InAppBrowser.open("YOUR_URL");
40
+ InAppBrowser.open({ url: "YOUR_URL" });
41
+ ```
42
+
43
+ ### Open WebView with Custom Dimensions
44
+
45
+ By default, the webview opens in fullscreen. You can set custom dimensions to control the size and position:
46
+
47
+ ```js
48
+ import { InAppBrowser } from '@capgo/inappbrowser'
49
+
50
+ // Open with custom dimensions (400x600 at position 50,100)
51
+ InAppBrowser.openWebView({
52
+ url: "YOUR_URL",
53
+ width: 400,
54
+ height: 600,
55
+ x: 50,
56
+ y: 100
57
+ });
58
+
59
+ // Update dimensions at runtime
60
+ InAppBrowser.updateDimensions({
61
+ width: 500,
62
+ height: 700,
63
+ x: 100,
64
+ y: 150
65
+ });
66
+ ```
67
+
68
+ **Touch Passthrough**: When custom dimensions are set (not fullscreen), touches outside the webview bounds will pass through to the underlying Capacitor webview, allowing the user to interact with your app in the exposed areas. This enables picture-in-picture style experiences where the InAppBrowser floats above your content.
69
+
70
+ ### Open WebView with Safe Margin
71
+
72
+ To create a webView with a 20px bottom margin (safe margin area outside the browser):
73
+
74
+ ```js
75
+ import { InAppBrowser } from '@capgo/inappbrowser'
76
+
77
+ InAppBrowser.openWebView({
78
+ url: "YOUR_URL",
79
+ enabledSafeBottomMargin: true
80
+ });
81
+ ```
82
+
83
+ Web platform is not supported. Use `window.open` instead.
84
+
85
+
86
+ ### Test app and code:
87
+
88
+ https://github.com/Cap-go/demo-app/blob/main/src/views/plugins/Web.vue
89
+
90
+ ### Camera usage
91
+
92
+ #### Android
93
+
94
+ Add the following to your `AndroidManifest.xml` file:
95
+
96
+ ```xml
97
+ <uses-permission android:name="android.permission.CAMERA" />
98
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
99
+ <uses-permission android:name="android.permission.RECORD_AUDIO"/>
100
+ ```
101
+
102
+ Then the permission will be asked when the camera is used.
103
+
104
+ #### iOS
105
+
106
+ Add the following to your `Info.plist` file:
107
+
108
+ ```xml
109
+ <key>NSCameraUsageDescription</key>
110
+ <string>We need access to the camera to record audio.</string>
111
+ ```
112
+
113
+ ### Microphone usage
114
+
115
+ #### Android
116
+
117
+ Add the following to your `AndroidManifest.xml` file:
118
+
119
+ ```xml
120
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
121
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
122
+ ```
123
+
124
+ Then the permission will be asked when the microphone is used.
125
+
126
+ #### iOS
127
+
128
+ Add the following to your `Info.plist` file:
129
+
130
+ ```xml
131
+ <key>NSMicrophoneUsageDescription</key>
132
+ <string>We need access to the microphone to record audio.</string>
133
+ ```
134
+
135
+ ### Location usage
136
+
137
+ #### Android
138
+
139
+ Add the following to your `AndroidManifest.xml` file:
140
+
141
+ ```xml
142
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
143
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
144
+ ```
145
+
146
+ Then the permission will be asked when location is requested by a website in the webview.
147
+
148
+ #### iOS
149
+
150
+ Add the following to your `Info.plist` file:
151
+
152
+ ```xml
153
+ <key>NSLocationWhenInUseUsageDescription</key>
154
+ <string>We need access to your location to provide location-based services.</string>
155
+ ```
156
+
157
+ ### Two way communication
158
+
159
+ With this plugin you can send events from the main app to the inappbrowser and vice versa.
160
+
161
+ > The data is sent as a JSON object, so no functions or other non-JSON-serializable types are allowed.
162
+
163
+ #### Main app to inappbrowser, detail object is mendatory
164
+
165
+ ```js
166
+ InAppBrowser.postMessage({ detail: { message: "myMessage" } });
167
+ ```
168
+
169
+ #### Receive event from native in the inappbrowser
170
+
171
+ ```js
172
+ window.addEventListener("messageFromNative", (event) => {
173
+ console.log(event);
174
+ });
175
+ ```
176
+
177
+ #### Send event from inappbrowser to main app, detail object is mendatory
178
+
179
+ ```js
180
+ window.mobileApp.postMessage({ detail: { message: "myMessage" } });
181
+ ```
182
+
183
+ #### Receive event from inappbrowser in the main app
184
+
185
+ ```js
186
+ InAppBrowser.addEventListener("messageFromWebview", (event) => {
187
+ console.log(event);
188
+ });
189
+ ```
190
+
191
+ ### Close inappbrowser from inappbrowser itself
192
+
193
+ ```js
194
+ window.mobileApp.close();
20
195
  ```
21
196
 
22
197
  ## API
23
198
 
24
199
  <docgen-index>
25
200
 
201
+ * [`goBack()`](#goback)
26
202
  * [`open(...)`](#open)
27
- * [`clearCookies()`](#clearcookies)
28
- * [`close()`](#close)
203
+ * [`clearCookies(...)`](#clearcookies)
204
+ * [`clearAllCookies()`](#clearallcookies)
205
+ * [`clearCache()`](#clearcache)
206
+ * [`getCookies(...)`](#getcookies)
207
+ * [`close(...)`](#close)
29
208
  * [`openWebView(...)`](#openwebview)
209
+ * [`executeScript(...)`](#executescript)
210
+ * [`postMessage(...)`](#postmessage)
30
211
  * [`setUrl(...)`](#seturl)
31
- * [`addListener('urlChangeEvent', ...)`](#addlistenerurlchangeevent)
32
- * [`addListener('closeEvent', ...)`](#addlistenercloseevent)
33
- * [`addListener('confirmBtnClicked', ...)`](#addlistenerconfirmbtnclicked)
212
+ * [`addListener('urlChangeEvent', ...)`](#addlistenerurlchangeevent-)
213
+ * [`addListener('buttonNearDoneClick', ...)`](#addlistenerbuttonneardoneclick-)
214
+ * [`addListener('closeEvent', ...)`](#addlistenercloseevent-)
215
+ * [`addListener('confirmBtnClicked', ...)`](#addlistenerconfirmbtnclicked-)
216
+ * [`addListener('messageFromWebview', ...)`](#addlistenermessagefromwebview-)
217
+ * [`addListener('browserPageLoaded', ...)`](#addlistenerbrowserpageloaded-)
218
+ * [`addListener('pageLoadError', ...)`](#addlistenerpageloaderror-)
34
219
  * [`removeAllListeners()`](#removealllisteners)
220
+ * [`reload()`](#reload)
221
+ * [`updateDimensions(...)`](#updatedimensions)
35
222
  * [Interfaces](#interfaces)
36
223
  * [Type Aliases](#type-aliases)
37
224
  * [Enums](#enums)
@@ -41,47 +228,119 @@ InAppBrowser.open("YOUR_URL");
41
228
  <docgen-api>
42
229
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
43
230
 
231
+ ### goBack()
232
+
233
+ ```typescript
234
+ goBack() => Promise<{ canGoBack: boolean; }>
235
+ ```
236
+
237
+ Navigates back in the WebView's history if possible
238
+
239
+ **Returns:** <code>Promise&lt;{ canGoBack: boolean; }&gt;</code>
240
+
241
+ **Since:** 7.21.0
242
+
243
+ --------------------
244
+
245
+
44
246
  ### open(...)
45
247
 
46
248
  ```typescript
47
- open(options: OpenOptions) => any
249
+ open(options: OpenOptions) => Promise<any>
48
250
  ```
49
251
 
50
- Open url in a new window fullscreen
252
+ Open url in a new window fullscreen, on android it use chrome custom tabs, on ios it use SFSafariViewController
51
253
 
52
254
  | Param | Type |
53
255
  | ------------- | --------------------------------------------------- |
54
256
  | **`options`** | <code><a href="#openoptions">OpenOptions</a></code> |
55
257
 
56
- **Returns:** <code>any</code>
258
+ **Returns:** <code>Promise&lt;any&gt;</code>
57
259
 
58
260
  **Since:** 0.1.0
59
261
 
60
262
  --------------------
61
263
 
62
264
 
63
- ### clearCookies()
265
+ ### clearCookies(...)
64
266
 
65
267
  ```typescript
66
- clearCookies() => any
268
+ clearCookies(options: ClearCookieOptions) => Promise<any>
67
269
  ```
68
270
 
69
- Clear all cookies
271
+ Clear cookies of url
70
272
 
71
- **Returns:** <code>any</code>
273
+ | Param | Type |
274
+ | ------------- | ----------------------------------------------------------------- |
275
+ | **`options`** | <code><a href="#clearcookieoptions">ClearCookieOptions</a></code> |
276
+
277
+ **Returns:** <code>Promise&lt;any&gt;</code>
72
278
 
73
279
  **Since:** 0.5.0
74
280
 
75
281
  --------------------
76
282
 
77
283
 
78
- ### close()
284
+ ### clearAllCookies()
79
285
 
80
286
  ```typescript
81
- close() => any
287
+ clearAllCookies() => Promise<any>
82
288
  ```
83
289
 
84
- **Returns:** <code>any</code>
290
+ Clear all cookies
291
+
292
+ **Returns:** <code>Promise&lt;any&gt;</code>
293
+
294
+ **Since:** 6.5.0
295
+
296
+ --------------------
297
+
298
+
299
+ ### clearCache()
300
+
301
+ ```typescript
302
+ clearCache() => Promise<any>
303
+ ```
304
+
305
+ Clear cache
306
+
307
+ **Returns:** <code>Promise&lt;any&gt;</code>
308
+
309
+ **Since:** 6.5.0
310
+
311
+ --------------------
312
+
313
+
314
+ ### getCookies(...)
315
+
316
+ ```typescript
317
+ getCookies(options: GetCookieOptions) => Promise<Record<string, string>>
318
+ ```
319
+
320
+ Get cookies for a specific URL.
321
+
322
+ | Param | Type | Description |
323
+ | ------------- | ------------------------------------------------------------- | -------------------------------------------------- |
324
+ | **`options`** | <code><a href="#getcookieoptions">GetCookieOptions</a></code> | The options, including the URL to get cookies for. |
325
+
326
+ **Returns:** <code>Promise&lt;<a href="#record">Record</a>&lt;string, string&gt;&gt;</code>
327
+
328
+ --------------------
329
+
330
+
331
+ ### close(...)
332
+
333
+ ```typescript
334
+ close(options?: CloseWebviewOptions | undefined) => Promise<any>
335
+ ```
336
+
337
+ Close the webview.
338
+
339
+ | Param | Type |
340
+ | ------------- | ------------------------------------------------------------------- |
341
+ | **`options`** | <code><a href="#closewebviewoptions">CloseWebviewOptions</a></code> |
342
+
343
+ **Returns:** <code>Promise&lt;any&gt;</code>
85
344
 
86
345
  --------------------
87
346
 
@@ -89,33 +348,72 @@ close() => any
89
348
  ### openWebView(...)
90
349
 
91
350
  ```typescript
92
- openWebView(options: OpenWebViewOptions) => any
351
+ openWebView(options: OpenWebViewOptions) => Promise<any>
93
352
  ```
94
353
 
95
- Open url in a new webview with toolbars
354
+ Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.
355
+
356
+ JavaScript Interface:
357
+ When you open a webview with this method, a JavaScript interface is automatically injected that provides:
358
+ - `window.mobileApp.close()`: Closes the webview from JavaScript
359
+ - `window.mobileApp.postMessage({detail: {message: "myMessage"}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview
96
360
 
97
361
  | Param | Type |
98
362
  | ------------- | ----------------------------------------------------------------- |
99
363
  | **`options`** | <code><a href="#openwebviewoptions">OpenWebViewOptions</a></code> |
100
364
 
101
- **Returns:** <code>any</code>
365
+ **Returns:** <code>Promise&lt;any&gt;</code>
102
366
 
103
367
  **Since:** 0.1.0
104
368
 
105
369
  --------------------
106
370
 
107
371
 
372
+ ### executeScript(...)
373
+
374
+ ```typescript
375
+ executeScript({ code }: { code: string; }) => Promise<void>
376
+ ```
377
+
378
+ Injects JavaScript code into the InAppBrowser window.
379
+
380
+ | Param | Type |
381
+ | --------- | ------------------------------ |
382
+ | **`__0`** | <code>{ code: string; }</code> |
383
+
384
+ --------------------
385
+
386
+
387
+ ### postMessage(...)
388
+
389
+ ```typescript
390
+ postMessage(options: { detail: Record<string, any>; }) => Promise<void>
391
+ ```
392
+
393
+ Sends an event to the webview(inappbrowser). you can listen to this event in the inappbrowser JS with window.addEventListener("messageFromNative", listenerFunc: (event: <a href="#record">Record</a>&lt;string, any&gt;) =&gt; void)
394
+ detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects
395
+ Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.
396
+
397
+ | Param | Type |
398
+ | ------------- | ------------------------------------------------------------------------- |
399
+ | **`options`** | <code>{ detail: <a href="#record">Record</a>&lt;string, any&gt;; }</code> |
400
+
401
+ --------------------
402
+
403
+
108
404
  ### setUrl(...)
109
405
 
110
406
  ```typescript
111
- setUrl(options: { url: string; }) => any
407
+ setUrl(options: { url: string; }) => Promise<any>
112
408
  ```
113
409
 
410
+ Sets the URL of the webview.
411
+
114
412
  | Param | Type |
115
413
  | ------------- | ----------------------------- |
116
414
  | **`options`** | <code>{ url: string; }</code> |
117
415
 
118
- **Returns:** <code>any</code>
416
+ **Returns:** <code>Promise&lt;any&gt;</code>
119
417
 
120
418
  --------------------
121
419
 
@@ -123,37 +421,53 @@ setUrl(options: { url: string; }) => any
123
421
  ### addListener('urlChangeEvent', ...)
124
422
 
125
423
  ```typescript
126
- addListener(eventName: "urlChangeEvent", listenerFunc: UrlChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
424
+ addListener(eventName: 'urlChangeEvent', listenerFunc: UrlChangeListener) => Promise<PluginListenerHandle>
127
425
  ```
128
426
 
129
- Listen for url change
427
+ Listen for url change, only for openWebView
130
428
 
131
429
  | Param | Type |
132
430
  | ------------------ | --------------------------------------------------------------- |
133
431
  | **`eventName`** | <code>'urlChangeEvent'</code> |
134
432
  | **`listenerFunc`** | <code><a href="#urlchangelistener">UrlChangeListener</a></code> |
135
433
 
136
- **Returns:** <code>any</code>
434
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
137
435
 
138
436
  **Since:** 0.0.1
139
437
 
140
438
  --------------------
141
439
 
142
440
 
441
+ ### addListener('buttonNearDoneClick', ...)
442
+
443
+ ```typescript
444
+ addListener(eventName: 'buttonNearDoneClick', listenerFunc: ButtonNearListener) => Promise<PluginListenerHandle>
445
+ ```
446
+
447
+ | Param | Type |
448
+ | ------------------ | ----------------------------------------------------------------- |
449
+ | **`eventName`** | <code>'buttonNearDoneClick'</code> |
450
+ | **`listenerFunc`** | <code><a href="#buttonnearlistener">ButtonNearListener</a></code> |
451
+
452
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
453
+
454
+ --------------------
455
+
456
+
143
457
  ### addListener('closeEvent', ...)
144
458
 
145
459
  ```typescript
146
- addListener(eventName: "closeEvent", listenerFunc: UrlChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
460
+ addListener(eventName: 'closeEvent', listenerFunc: UrlChangeListener) => Promise<PluginListenerHandle>
147
461
  ```
148
462
 
149
- Listen for close click
463
+ Listen for close click only for openWebView
150
464
 
151
465
  | Param | Type |
152
466
  | ------------------ | --------------------------------------------------------------- |
153
467
  | **`eventName`** | <code>'closeEvent'</code> |
154
468
  | **`listenerFunc`** | <code><a href="#urlchangelistener">UrlChangeListener</a></code> |
155
469
 
156
- **Returns:** <code>any</code>
470
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
157
471
 
158
472
  **Since:** 0.4.0
159
473
 
@@ -163,76 +477,242 @@ Listen for close click
163
477
  ### addListener('confirmBtnClicked', ...)
164
478
 
165
479
  ```typescript
166
- addListener(eventName: "confirmBtnClicked", listenerFunc: ConfirmBtnListener) => Promise<PluginListenerHandle> & PluginListenerHandle
480
+ addListener(eventName: 'confirmBtnClicked', listenerFunc: ConfirmBtnListener) => Promise<PluginListenerHandle>
167
481
  ```
168
482
 
169
- Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS
483
+ Will be triggered when user clicks on confirm button when disclaimer is required,
484
+ works with openWebView shareDisclaimer and closeModal
170
485
 
171
486
  | Param | Type |
172
487
  | ------------------ | ----------------------------------------------------------------- |
173
488
  | **`eventName`** | <code>'confirmBtnClicked'</code> |
174
489
  | **`listenerFunc`** | <code><a href="#confirmbtnlistener">ConfirmBtnListener</a></code> |
175
490
 
176
- **Returns:** <code>any</code>
491
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
177
492
 
178
493
  **Since:** 0.0.1
179
494
 
180
495
  --------------------
181
496
 
182
497
 
498
+ ### addListener('messageFromWebview', ...)
499
+
500
+ ```typescript
501
+ addListener(eventName: 'messageFromWebview', listenerFunc: (event: { detail: Record<string, any>; }) => void) => Promise<PluginListenerHandle>
502
+ ```
503
+
504
+ Will be triggered when event is sent from webview(inappbrowser), to send an event to the main app use window.mobileApp.postMessage({ "detail": { "message": "myMessage" } })
505
+ detail is the data you want to send to the main app, it's a requirement of Capacitor we cannot send direct objects
506
+ Your object has to be serializable to JSON, no functions or other non-JSON-serializable types are allowed.
507
+
508
+ This method is inject at runtime in the webview
509
+
510
+ | Param | Type |
511
+ | ------------------ | --------------------------------------------------------------------------------------------- |
512
+ | **`eventName`** | <code>'messageFromWebview'</code> |
513
+ | **`listenerFunc`** | <code>(event: { detail: <a href="#record">Record</a>&lt;string, any&gt;; }) =&gt; void</code> |
514
+
515
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
516
+
517
+ --------------------
518
+
519
+
520
+ ### addListener('browserPageLoaded', ...)
521
+
522
+ ```typescript
523
+ addListener(eventName: 'browserPageLoaded', listenerFunc: () => void) => Promise<PluginListenerHandle>
524
+ ```
525
+
526
+ Will be triggered when page is loaded
527
+
528
+ | Param | Type |
529
+ | ------------------ | -------------------------------- |
530
+ | **`eventName`** | <code>'browserPageLoaded'</code> |
531
+ | **`listenerFunc`** | <code>() =&gt; void</code> |
532
+
533
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
534
+
535
+ --------------------
536
+
537
+
538
+ ### addListener('pageLoadError', ...)
539
+
540
+ ```typescript
541
+ addListener(eventName: 'pageLoadError', listenerFunc: () => void) => Promise<PluginListenerHandle>
542
+ ```
543
+
544
+ Will be triggered when page load error
545
+
546
+ | Param | Type |
547
+ | ------------------ | ---------------------------- |
548
+ | **`eventName`** | <code>'pageLoadError'</code> |
549
+ | **`listenerFunc`** | <code>() =&gt; void</code> |
550
+
551
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
552
+
553
+ --------------------
554
+
555
+
183
556
  ### removeAllListeners()
184
557
 
185
558
  ```typescript
186
- removeAllListeners() => any
559
+ removeAllListeners() => Promise<void>
187
560
  ```
188
561
 
189
562
  Remove all listeners for this plugin.
190
563
 
191
- **Returns:** <code>any</code>
564
+ **Since:** 1.0.0
565
+
566
+ --------------------
567
+
568
+
569
+ ### reload()
570
+
571
+ ```typescript
572
+ reload() => Promise<any>
573
+ ```
574
+
575
+ Reload the current web page.
576
+
577
+ **Returns:** <code>Promise&lt;any&gt;</code>
192
578
 
193
579
  **Since:** 1.0.0
194
580
 
195
581
  --------------------
196
582
 
197
583
 
584
+ ### updateDimensions(...)
585
+
586
+ ```typescript
587
+ updateDimensions(options: DimensionOptions) => Promise<void>
588
+ ```
589
+
590
+ Update the dimensions of the webview.
591
+ Allows changing the size and position of the webview at runtime.
592
+
593
+ | Param | Type | Description |
594
+ | ------------- | ------------------------------------------------------------- | --------------------------------------- |
595
+ | **`options`** | <code><a href="#dimensionoptions">DimensionOptions</a></code> | Dimension options (width, height, x, y) |
596
+
597
+ --------------------
598
+
599
+
198
600
  ### Interfaces
199
601
 
200
602
 
201
603
  #### OpenOptions
202
604
 
203
- | Prop | Type | Description | Since |
204
- | ---------------------------- | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | ----- |
205
- | **`url`** | <code>string</code> | Target URL to load. | 0.1.0 |
206
- | **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | 0.1.0 |
207
- | **`isPresentAfterPageLoad`** | <code>boolean</code> | if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | 0.1.0 |
208
- | **`preventDeeplink`** | <code>boolean</code> | | |
605
+ | Prop | Type | Description | Since |
606
+ | ---------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------- | ----- |
607
+ | **`url`** | <code>string</code> | Target URL to load. | 0.1.0 |
608
+ | **`isPresentAfterPageLoad`** | <code>boolean</code> | if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | 0.1.0 |
609
+ | **`preventDeeplink`** | <code>boolean</code> | if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link | 0.1.0 |
209
610
 
210
611
 
211
- #### Headers
612
+ #### ClearCookieOptions
613
+
614
+ | Prop | Type |
615
+ | --------- | ------------------- |
616
+ | **`url`** | <code>string</code> |
617
+
618
+
619
+ #### HttpCookie
620
+
621
+ | Prop | Type | Description |
622
+ | ----------- | ------------------- | ------------------------ |
623
+ | **`url`** | <code>string</code> | The URL of the cookie. |
624
+ | **`key`** | <code>string</code> | The key of the cookie. |
625
+ | **`value`** | <code>string</code> | The value of the cookie. |
626
+
627
+
628
+ #### GetCookieOptions
629
+
630
+ | Prop | Type |
631
+ | --------------------- | -------------------- |
632
+ | **`url`** | <code>string</code> |
633
+ | **`includeHttpOnly`** | <code>boolean</code> |
634
+
635
+
636
+ #### CloseWebviewOptions
637
+
638
+ | Prop | Type | Description | Default |
639
+ | ---------------- | -------------------- | -------------------------------------------------------- | ----------------- |
640
+ | **`isAnimated`** | <code>boolean</code> | Whether the webview closing is animated or not, ios only | <code>true</code> |
212
641
 
213
642
 
214
643
  #### OpenWebViewOptions
215
644
 
216
- | Prop | Type | Description | Default | Since |
217
- | ---------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | ----- |
218
- | **`url`** | <code>string</code> | Target URL to load. | | 0.1.0 |
219
- | **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | | 0.1.0 |
220
- | **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | share options | | 0.1.0 |
221
- | **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type | <code>ToolBarType.DEFAULT</code> | 0.1.0 |
222
- | **`shareSubject`** | <code>string</code> | Share subject | | 0.1.0 |
223
- | **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
224
- | **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser, only on IOS | <code>BackgroundColor.BLACK</code> | 0.1.0 |
225
- | **`isPresentAfterPageLoad`** | <code>boolean</code> | Open url in a new window fullscreen isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | <code>false</code> | 0.1.0 |
645
+ | Prop | Type | Description | Default | Since |
646
+ | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | ------ |
647
+ | **`url`** | <code>string</code> | Target URL to load. | | 0.1.0 |
648
+ | **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | | 0.1.0 |
649
+ | **`credentials`** | <code><a href="#credentials">Credentials</a></code> | <a href="#credentials">Credentials</a> to send with the request and all subsequent requests for the same host. | | 6.1.0 |
650
+ | **`materialPicker`** | <code>boolean</code> | materialPicker: if true, uses Material Design theme for date and time pickers on Android. This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers. | <code>false</code> | 7.4.1 |
651
+ | **`jsInterface`** | | JavaScript Interface: The webview automatically injects a JavaScript interface providing: - `window.mobileApp.close()`: Closes the webview from JavaScript - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via "messageFromWebview" event) | | 6.10.0 |
652
+ | **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | Share options for the webview. When provided, shows a disclaimer dialog before sharing content. This is useful for: - Warning users about sharing sensitive information - Getting user consent before sharing - Explaining what will be shared - Complying with privacy regulations Note: shareSubject is required when using shareDisclaimer | | 0.1.0 |
653
+ | **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type determines the appearance and behavior of the browser's toolbar - "activity": Shows a simple toolbar with just a close button and share button - "navigation": Shows a full navigation toolbar with back/forward buttons - "blank": Shows no toolbar - "": Default toolbar with close button | <code>ToolBarType.DEFAULT</code> | 0.1.0 |
654
+ | **`shareSubject`** | <code>string</code> | Subject text for sharing. Required when using shareDisclaimer. This text will be used as the subject line when sharing content. | | 0.1.0 |
655
+ | **`title`** | <code>string</code> | Title of the browser | <code>"New Window"</code> | 0.1.0 |
656
+ | **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser | <code>BackgroundColor.BLACK</code> | 0.1.0 |
657
+ | **`activeNativeNavigationForWebview`** | <code>boolean</code> | If true, enables native navigation gestures within the webview. - Android: Native back button navigates within webview history - iOS: Enables swipe left/right gestures for back/forward navigation | <code>false (Android), true (iOS - enabled by default)</code> | |
658
+ | **`disableGoBackOnNativeApplication`** | <code>boolean</code> | Disable the possibility to go back on native application, useful to force user to stay on the webview, Android only | <code>false</code> | |
659
+ | **`isPresentAfterPageLoad`** | <code>boolean</code> | Open url in a new window fullscreen isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | <code>false</code> | 0.1.0 |
660
+ | **`isInspectable`** | <code>boolean</code> | Whether the website in the webview is inspectable or not, ios only | <code>false</code> | |
661
+ | **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
662
+ | **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
663
+ | **`closeModal`** | <code>boolean</code> | CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately. | <code>false</code> | 1.1.0 |
664
+ | **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button | <code>"Close"</code> | 1.1.0 |
665
+ | **`closeModalDescription`** | <code>string</code> | CloseModalDescription: description of the confirm when user clicks on close button | <code>"Are you sure you want to close this window?"</code> | 1.1.0 |
666
+ | **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button | <code>"Close"</code> | 1.1.0 |
667
+ | **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button | <code>"Cancel"</code> | 1.1.0 |
668
+ | **`visibleTitle`** | <code>boolean</code> | visibleTitle: if true the website title would be shown else shown empty | <code>true</code> | 1.2.5 |
669
+ | **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>"#ffffff"</code> | 1.2.5 |
670
+ | **`toolbarTextColor`** | <code>string</code> | toolbarTextColor: color of the buttons and title in the toolbar in hex format When set, it overrides the automatic light/dark mode detection for text color | <code>calculated based on toolbarColor brightness</code> | 6.10.0 |
671
+ | **`showArrow`** | <code>boolean</code> | showArrow: if true an arrow would be shown instead of cross for closing the window | <code>false</code> | 1.2.5 |
672
+ | **`ignoreUntrustedSSLError`** | <code>boolean</code> | ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website. | <code>false</code> | 6.1.0 |
673
+ | **`preShowScript`** | <code>string</code> | preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser. This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds) | | 6.6.0 |
674
+ | **`preShowScriptInjectionTime`** | <code>'documentStart' \| 'pageLoad'</code> | preShowScriptInjectionTime: controls when the preShowScript is injected. - "documentStart": injects before any page JavaScript runs (good for polyfills like Firebase) - "pageLoad": injects after page load (default, original behavior) | <code>"pageLoad"</code> | 7.26.0 |
675
+ | **`proxyRequests`** | <code>string</code> | proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only) | | 6.9.0 |
676
+ | **`buttonNearDone`** | <code>{ ios: { iconType: 'sf-symbol' \| 'asset'; icon: string; }; android: { iconType: 'asset' \| 'vector'; icon: string; width?: number; height?: number; }; }</code> | buttonNearDone allows for a creation of a custom button near the done/close button. The button is only shown when toolbarType is not "activity", "navigation", or "blank". For Android: - iconType must be "asset" - icon path should be in the public folder (e.g. "monkey.svg") - width and height are optional, defaults to 48dp - button is positioned at the end of toolbar with 8dp margin For iOS: - iconType can be "sf-symbol" or "asset" - for sf-symbol, icon should be the symbol name - for asset, icon should be the asset name | | 6.7.0 |
677
+ | **`textZoom`** | <code>number</code> | textZoom: sets the text zoom of the page in percent. Allows users to increase or decrease the text size for better readability. | <code>100</code> | 7.6.0 |
678
+ | **`preventDeeplink`** | <code>boolean</code> | preventDeeplink: if true, the deeplink will not be opened, if false the deeplink will be opened when clicked on the link. on IOS each schema need to be added to info.plist file under LSApplicationQueriesSchemes when false to make it work. | <code>false</code> | 0.1.0 |
679
+ | **`authorizedAppLinks`** | <code>string[]</code> | List of base URLs whose hosts are treated as authorized App Links (Android) and Universal Links (iOS). - On both platforms, only HTTPS links whose host matches any entry in this list will attempt to open via the corresponding native application. - If the app is not installed or the system cannot handle the link, the URL will continue loading inside the in-app browser. - Matching is host-based (case-insensitive), ignoring the "www." prefix. - When `preventDeeplink` is enabled, all external handling is blocked regardless of this list. | <code>[]</code> | 7.12.0 |
680
+ | **`enabledSafeBottomMargin`** | <code>boolean</code> | If true, the webView will not take the full height and will have a 20px margin at the bottom. This creates a safe margin area outside the browser view. | <code>false</code> | 7.13.0 |
681
+ | **`useTopInset`** | <code>boolean</code> | When true, applies the system status bar inset as the WebView top margin on Android. Keeps the legacy 0px margin by default for apps that handle padding themselves. | <code>false</code> | |
682
+ | **`enableGooglePaySupport`** | <code>boolean</code> | enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API. This fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy. Only enable this if you need Google Pay functionality as it allows popup windows. When enabled: - Allows popup windows for Google Pay authentication - Sets proper CORS headers for Payment Request API - Enables multiple window support in WebView - Configures secure context for payment processing | <code>false</code> | 7.13.0 |
683
+ | **`blockedHosts`** | <code>string[]</code> | blockedHosts: List of host patterns that should be blocked from loading in the InAppBrowser's internal navigations. Any request inside WebView to a URL with a host matching any of these patterns will be blocked. Supports wildcard patterns like: - "*.example.com" to block all subdomains - "www.example.*" to block wildcard domain extensions | <code>[]</code> | 7.17.0 |
684
+ | **`width`** | <code>number</code> | Width of the webview in pixels. If not set, webview will be fullscreen width. | <code>undefined (fullscreen)</code> | |
685
+ | **`height`** | <code>number</code> | Height of the webview in pixels. If not set, webview will be fullscreen height. | <code>undefined (fullscreen)</code> | |
686
+ | **`x`** | <code>number</code> | X position of the webview in pixels from the left edge. Only effective when width is set. | <code>0</code> | |
687
+ | **`y`** | <code>number</code> | Y position of the webview in pixels from the top edge. Only effective when height is set. | <code>0</code> | |
688
+
689
+
690
+ #### Headers
691
+
692
+
693
+ #### Credentials
694
+
695
+ | Prop | Type |
696
+ | -------------- | ------------------- |
697
+ | **`username`** | <code>string</code> |
698
+ | **`password`** | <code>string</code> |
226
699
 
227
700
 
228
701
  #### DisclaimerOptions
229
702
 
230
- | Prop | Type |
231
- | ---------------- | ------------------- |
232
- | **`title`** | <code>string</code> |
233
- | **`message`** | <code>string</code> |
234
- | **`confirmBtn`** | <code>string</code> |
235
- | **`cancelBtn`** | <code>string</code> |
703
+ | Prop | Type | Description | Default |
704
+ | ---------------- | ------------------- | -------------------------------------- | ---------------------- |
705
+ | **`title`** | <code>string</code> | Title of the disclaimer dialog | <code>"Title"</code> |
706
+ | **`message`** | <code>string</code> | Message shown in the disclaimer dialog | <code>"Message"</code> |
707
+ | **`confirmBtn`** | <code>string</code> | Text for the confirm button | <code>"Confirm"</code> |
708
+ | **`cancelBtn`** | <code>string</code> | Text for the cancel button | <code>"Cancel"</code> |
709
+
710
+
711
+ #### PluginListenerHandle
712
+
713
+ | Prop | Type |
714
+ | ------------ | ----------------------------------------- |
715
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
236
716
 
237
717
 
238
718
  #### UrlEvent
@@ -242,13 +722,6 @@ Remove all listeners for this plugin.
242
722
  | **`url`** | <code>string</code> | Emit when the url changes | 0.0.1 |
243
723
 
244
724
 
245
- #### PluginListenerHandle
246
-
247
- | Prop | Type |
248
- | ------------ | ------------------------- |
249
- | **`remove`** | <code>() =&gt; any</code> |
250
-
251
-
252
725
  #### BtnEvent
253
726
 
254
727
  | Prop | Type | Description | Since |
@@ -256,14 +729,67 @@ Remove all listeners for this plugin.
256
729
  | **`url`** | <code>string</code> | Emit when a button is clicked. | 0.0.1 |
257
730
 
258
731
 
732
+ #### DimensionOptions
733
+
734
+ | Prop | Type | Description |
735
+ | ------------ | ------------------- | --------------------------------------- |
736
+ | **`width`** | <code>number</code> | Width of the webview in pixels |
737
+ | **`height`** | <code>number</code> | Height of the webview in pixels |
738
+ | **`x`** | <code>number</code> | X position from the left edge in pixels |
739
+ | **`y`** | <code>number</code> | Y position from the top edge in pixels |
740
+
741
+
259
742
  ### Type Aliases
260
743
 
261
744
 
745
+ #### ClearCookieOptions
746
+
747
+ <code><a href="#omit">Omit</a>&lt;<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'&gt;</code>
748
+
749
+
750
+ #### Omit
751
+
752
+ Construct a type with the properties of T except for those in type K.
753
+
754
+ <code><a href="#pick">Pick</a>&lt;T, <a href="#exclude">Exclude</a>&lt;keyof T, K&gt;&gt;</code>
755
+
756
+
757
+ #### Pick
758
+
759
+ From T, pick a set of properties whose keys are in the union K
760
+
761
+ <code>{
262
762
  [P in K]: T[P];
263
763
  }</code>
764
+
765
+
766
+ #### Exclude
767
+
768
+ <a href="#exclude">Exclude</a> from T those types that are assignable to U
769
+
770
+ <code>T extends U ? never : T</code>
771
+
772
+
773
+ #### Record
774
+
775
+ Construct a type with a set of properties K of type T
776
+
777
+ <code>{
264
778
  [P in K]: T;
265
779
  }</code>
780
+
781
+
782
+ #### GetCookieOptions
783
+
784
+ <code><a href="#omit">Omit</a>&lt;<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'&gt;</code>
785
+
786
+
266
787
  #### UrlChangeListener
267
788
 
268
789
  <code>(state: <a href="#urlevent">UrlEvent</a>): void</code>
269
790
 
270
791
 
792
+ #### ButtonNearListener
793
+
794
+ <code>(state: object): void</code>
795
+
796
+
271
797
  #### ConfirmBtnListener
272
798
 
273
799
  <code>(state: <a href="#btnevent">BtnEvent</a>): void</code>
@@ -274,20 +800,20 @@ Remove all listeners for this plugin.
274
800
 
275
801
  #### ToolBarType
276
802
 
277
- | Members | Value |
278
- | ---------------- | ------------------------- |
279
- | **`ACTIVITY`** | <code>"activity"</code> |
280
- | **`NAVIGATION`** | <code>"navigation"</code> |
281
- | **`BLANK`** | <code>"blank"</code> |
282
- | **`DEFAULT`** | <code>""</code> |
803
+ | Members | Value | Description | Since |
804
+ | ---------------- | ------------------------- | ---------------------------------------------------------------- | ----- |
805
+ | **`ACTIVITY`** | <code>'activity'</code> | Shows a simple toolbar with just a close button and share button | 0.1.0 |
806
+ | **`COMPACT`** | <code>'compact'</code> | Shows a simple toolbar with just a close button | 7.6.8 |
807
+ | **`NAVIGATION`** | <code>'navigation'</code> | Shows a full navigation toolbar with back/forward buttons | 0.1.0 |
808
+ | **`BLANK`** | <code>'blank'</code> | Shows no toolbar | 0.1.0 |
283
809
 
284
810
 
285
811
  #### BackgroundColor
286
812
 
287
813
  | Members | Value |
288
814
  | ----------- | -------------------- |
289
- | **`WHITE`** | <code>"white"</code> |
290
- | **`BLACK`** | <code>"black"</code> |
815
+ | **`WHITE`** | <code>'white'</code> |
816
+ | **`BLACK`** | <code>'black'</code> |
291
817
 
292
818
  </docgen-api>
293
819