@capgo/inappbrowser 8.0.0 → 8.0.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.
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 +3023 -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/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift +952 -0
  34. package/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift +2006 -0
  35. package/package.json +30 -30
  36. package/ios/Plugin/Assets.xcassets/Back.imageset/Back.png +0 -0
  37. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@2x.png +0 -0
  38. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@3x.png +0 -0
  39. package/ios/Plugin/Assets.xcassets/Back.imageset/Contents.json +0 -26
  40. package/ios/Plugin/Assets.xcassets/Contents.json +0 -6
  41. package/ios/Plugin/Assets.xcassets/Forward.imageset/Contents.json +0 -26
  42. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward.png +0 -0
  43. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@2x.png +0 -0
  44. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@3x.png +0 -0
  45. package/ios/Plugin/InAppBrowserPlugin.h +0 -10
  46. package/ios/Plugin/InAppBrowserPlugin.m +0 -17
  47. package/ios/Plugin/InAppBrowserPlugin.swift +0 -203
  48. package/ios/Plugin/Info.plist +0 -24
  49. package/ios/Plugin/WKWebViewController.swift +0 -784
  50. /package/ios/{Plugin → Sources/InAppBrowserPlugin}/Enums.swift +0 -0
@@ -1,4 +1,4 @@
1
- import type { PluginListenerHandle } from "@capacitor/core";
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
2
  export interface UrlEvent {
3
3
  /**
4
4
  * Emit when the url changes
@@ -17,19 +17,47 @@ export interface BtnEvent {
17
17
  }
18
18
  export type UrlChangeListener = (state: UrlEvent) => void;
19
19
  export type ConfirmBtnListener = (state: BtnEvent) => void;
20
+ export type ButtonNearListener = (state: object) => void;
20
21
  export declare enum BackgroundColor {
21
22
  WHITE = "white",
22
23
  BLACK = "black"
23
24
  }
24
25
  export declare enum ToolBarType {
26
+ /**
27
+ * Shows a simple toolbar with just a close button and share button
28
+ * @since 0.1.0
29
+ */
25
30
  ACTIVITY = "activity",
31
+ /**
32
+ * Shows a simple toolbar with just a close button
33
+ * @since 7.6.8
34
+ */
35
+ COMPACT = "compact",
36
+ /**
37
+ * Shows a full navigation toolbar with back/forward buttons
38
+ * @since 0.1.0
39
+ */
26
40
  NAVIGATION = "navigation",
27
- BLANK = "blank",
28
- DEFAULT = ""
41
+ /**
42
+ * Shows no toolbar
43
+ * @since 0.1.0
44
+ */
45
+ BLANK = "blank"
29
46
  }
30
47
  export interface Headers {
31
48
  [key: string]: string;
32
49
  }
50
+ export interface GetCookieOptions {
51
+ url: string;
52
+ includeHttpOnly?: boolean;
53
+ }
54
+ export interface ClearCookieOptions {
55
+ url: string;
56
+ }
57
+ export interface Credentials {
58
+ username: string;
59
+ password: string;
60
+ }
33
61
  export interface OpenOptions {
34
62
  /**
35
63
  * Target URL to load.
@@ -37,116 +65,677 @@ export interface OpenOptions {
37
65
  */
38
66
  url: string;
39
67
  /**
40
- * Headers to send with the request.
68
+ * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.
41
69
  * @since 0.1.0
42
70
  */
43
- headers?: Headers;
71
+ isPresentAfterPageLoad?: boolean;
44
72
  /**
45
- * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.
73
+ * if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link
46
74
  * @since 0.1.0
47
75
  */
48
- isPresentAfterPageLoad?: boolean;
49
76
  preventDeeplink?: boolean;
50
77
  }
51
78
  export interface DisclaimerOptions {
79
+ /**
80
+ * Title of the disclaimer dialog
81
+ * @default "Title"
82
+ */
52
83
  title: string;
84
+ /**
85
+ * Message shown in the disclaimer dialog
86
+ * @default "Message"
87
+ */
53
88
  message: string;
89
+ /**
90
+ * Text for the confirm button
91
+ * @default "Confirm"
92
+ */
54
93
  confirmBtn: string;
94
+ /**
95
+ * Text for the cancel button
96
+ * @default "Cancel"
97
+ */
55
98
  cancelBtn: string;
56
99
  }
100
+ export interface CloseWebviewOptions {
101
+ /**
102
+ * Whether the webview closing is animated or not, ios only
103
+ * @default true
104
+ */
105
+ isAnimated?: boolean;
106
+ }
57
107
  export interface OpenWebViewOptions {
58
108
  /**
59
109
  * Target URL to load.
60
110
  * @since 0.1.0
111
+ * @example "https://capgo.app"
61
112
  */
62
113
  url: string;
63
114
  /**
64
115
  * Headers to send with the request.
65
116
  * @since 0.1.0
117
+ * @example
118
+ * headers: {
119
+ * "Custom-Header": "test-value",
120
+ * "Authorization": "Bearer test-token"
121
+ * }
122
+ * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/
66
123
  */
67
124
  headers?: Headers;
68
125
  /**
69
- * share options
126
+ * Credentials to send with the request and all subsequent requests for the same host.
127
+ * @since 6.1.0
128
+ * @example
129
+ * credentials: {
130
+ * username: "test-user",
131
+ * password: "test-pass"
132
+ * }
133
+ * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/
134
+ */
135
+ credentials?: Credentials;
136
+ /**
137
+ * materialPicker: if true, uses Material Design theme for date and time pickers on Android.
138
+ * This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers.
139
+ * @since 7.4.1
140
+ * @default false
141
+ * @example
142
+ * materialPicker: true
143
+ * Test URL: https://show-picker.glitch.me/demo.html
144
+ */
145
+ materialPicker?: boolean;
146
+ /**
147
+ * JavaScript Interface:
148
+ * The webview automatically injects a JavaScript interface providing:
149
+ * - `window.mobileApp.close()`: Closes the webview from JavaScript
150
+ * - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via "messageFromWebview" event)
151
+ *
152
+ * @example
153
+ * // In your webpage loaded in the webview:
154
+ * document.getElementById("closeBtn").addEventListener("click", () => {
155
+ * window.mobileApp.close();
156
+ * });
157
+ *
158
+ * // Send data to the app
159
+ * window.mobileApp.postMessage({ action: "login", data: { user: "test" }});
160
+ *
161
+ * @since 6.10.0
162
+ */
163
+ jsInterface?: never;
164
+ /**
165
+ * Share options for the webview. When provided, shows a disclaimer dialog before sharing content.
166
+ * This is useful for:
167
+ * - Warning users about sharing sensitive information
168
+ * - Getting user consent before sharing
169
+ * - Explaining what will be shared
170
+ * - Complying with privacy regulations
171
+ *
172
+ * Note: shareSubject is required when using shareDisclaimer
70
173
  * @since 0.1.0
174
+ * @example
175
+ * shareDisclaimer: {
176
+ * title: "Disclaimer",
177
+ * message: "This is a test disclaimer",
178
+ * confirmBtn: "Accept",
179
+ * cancelBtn: "Decline"
180
+ * }
181
+ * Test URL: https://capgo.app
71
182
  */
72
183
  shareDisclaimer?: DisclaimerOptions;
73
184
  /**
74
- * Toolbar type
185
+ * Toolbar type determines the appearance and behavior of the browser's toolbar
186
+ * - "activity": Shows a simple toolbar with just a close button and share button
187
+ * - "navigation": Shows a full navigation toolbar with back/forward buttons
188
+ * - "blank": Shows no toolbar
189
+ * - "": Default toolbar with close button
75
190
  * @since 0.1.0
76
191
  * @default ToolBarType.DEFAULT
192
+ * @example
193
+ * toolbarType: ToolBarType.ACTIVITY,
194
+ * title: "Activity Toolbar Test"
195
+ * Test URL: https://capgo.app
77
196
  */
78
197
  toolbarType?: ToolBarType;
79
198
  /**
80
- * Share subject
199
+ * Subject text for sharing. Required when using shareDisclaimer.
200
+ * This text will be used as the subject line when sharing content.
81
201
  * @since 0.1.0
202
+ * @example "Share this page"
82
203
  */
83
204
  shareSubject?: string;
84
205
  /**
85
206
  * Title of the browser
86
207
  * @since 0.1.0
87
- * @default 'New Window'
208
+ * @default "New Window"
209
+ * @example "Camera Test"
88
210
  */
89
- title: string;
211
+ title?: string;
90
212
  /**
91
- * Background color of the browser, only on IOS
213
+ * Background color of the browser
92
214
  * @since 0.1.0
93
215
  * @default BackgroundColor.BLACK
94
216
  */
95
217
  backgroundColor?: BackgroundColor;
218
+ /**
219
+ * If true, enables native navigation gestures within the webview.
220
+ * - Android: Native back button navigates within webview history
221
+ * - iOS: Enables swipe left/right gestures for back/forward navigation
222
+ * @default false (Android), true (iOS - enabled by default)
223
+ * @example
224
+ * activeNativeNavigationForWebview: true,
225
+ * disableGoBackOnNativeApplication: true
226
+ * Test URL: https://capgo.app
227
+ */
228
+ activeNativeNavigationForWebview?: boolean;
229
+ /**
230
+ * Disable the possibility to go back on native application,
231
+ * useful to force user to stay on the webview, Android only
232
+ * @default false
233
+ * @example
234
+ * disableGoBackOnNativeApplication: true
235
+ * Test URL: https://capgo.app
236
+ */
237
+ disableGoBackOnNativeApplication?: boolean;
96
238
  /**
97
239
  * Open url in a new window fullscreen
98
- *
99
240
  * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.
100
241
  * @since 0.1.0
101
242
  * @default false
243
+ * @example
244
+ * isPresentAfterPageLoad: true,
245
+ * preShowScript: "await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });"
246
+ * Test URL: https://capgo.app
102
247
  */
103
248
  isPresentAfterPageLoad?: boolean;
249
+ /**
250
+ * Whether the website in the webview is inspectable or not, ios only
251
+ * @default false
252
+ */
253
+ isInspectable?: boolean;
254
+ /**
255
+ * Whether the webview opening is animated or not, ios only
256
+ * @default true
257
+ */
258
+ isAnimated?: boolean;
259
+ /**
260
+ * Shows a reload button that reloads the web page
261
+ * @since 1.0.15
262
+ * @default false
263
+ * @example
264
+ * showReloadButton: true
265
+ * Test URL: https://capgo.app
266
+ */
267
+ showReloadButton?: boolean;
268
+ /**
269
+ * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.
270
+ * @since 1.1.0
271
+ * @default false
272
+ * @example
273
+ * closeModal: true,
274
+ * closeModalTitle: "Close Window",
275
+ * closeModalDescription: "Are you sure you want to close?",
276
+ * closeModalOk: "Yes, close",
277
+ * closeModalCancel: "No, stay"
278
+ * Test URL: https://capgo.app
279
+ */
280
+ closeModal?: boolean;
281
+ /**
282
+ * CloseModalTitle: title of the confirm when user clicks on close button
283
+ * @since 1.1.0
284
+ * @default "Close"
285
+ */
286
+ closeModalTitle?: string;
287
+ /**
288
+ * CloseModalDescription: description of the confirm when user clicks on close button
289
+ * @since 1.1.0
290
+ * @default "Are you sure you want to close this window?"
291
+ */
292
+ closeModalDescription?: string;
293
+ /**
294
+ * CloseModalOk: text of the confirm button when user clicks on close button
295
+ * @since 1.1.0
296
+ * @default "Close"
297
+ */
298
+ closeModalOk?: string;
299
+ /**
300
+ * CloseModalCancel: text of the cancel button when user clicks on close button
301
+ * @since 1.1.0
302
+ * @default "Cancel"
303
+ */
304
+ closeModalCancel?: string;
305
+ /**
306
+ * visibleTitle: if true the website title would be shown else shown empty
307
+ * @since 1.2.5
308
+ * @default true
309
+ */
310
+ visibleTitle?: boolean;
311
+ /**
312
+ * toolbarColor: color of the toolbar in hex format
313
+ * @since 1.2.5
314
+ * @default "#ffffff"
315
+ * @example
316
+ * toolbarColor: "#FF5733"
317
+ * Test URL: https://capgo.app
318
+ */
319
+ toolbarColor?: string;
320
+ /**
321
+ * toolbarTextColor: color of the buttons and title in the toolbar in hex format
322
+ * When set, it overrides the automatic light/dark mode detection for text color
323
+ * @since 6.10.0
324
+ * @default calculated based on toolbarColor brightness
325
+ * @example
326
+ * toolbarTextColor: "#FFFFFF"
327
+ * Test URL: https://capgo.app
328
+ */
329
+ toolbarTextColor?: string;
330
+ /**
331
+ * showArrow: if true an arrow would be shown instead of cross for closing the window
332
+ * @since 1.2.5
333
+ * @default false
334
+ * @example
335
+ * showArrow: true
336
+ * Test URL: https://capgo.app
337
+ */
338
+ showArrow?: boolean;
339
+ /**
340
+ * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.
341
+ * @since 6.1.0
342
+ * @default false
343
+ */
344
+ ignoreUntrustedSSLError?: boolean;
345
+ /**
346
+ * preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser.
347
+ * This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds)
348
+ * @since 6.6.0
349
+ * @example
350
+ * preShowScript: "await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });"
351
+ * Test URL: https://capgo.app
352
+ */
353
+ preShowScript?: string;
354
+ /**
355
+ * preShowScriptInjectionTime: controls when the preShowScript is injected.
356
+ * - "documentStart": injects before any page JavaScript runs (good for polyfills like Firebase)
357
+ * - "pageLoad": injects after page load (default, original behavior)
358
+ * @since 7.26.0
359
+ * @default "pageLoad"
360
+ * @example
361
+ * preShowScriptInjectionTime: "documentStart"
362
+ */
363
+ preShowScriptInjectionTime?: 'documentStart' | 'pageLoad';
364
+ /**
365
+ * proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only)
366
+ * @since 6.9.0
367
+ */
368
+ proxyRequests?: string;
369
+ /**
370
+ * buttonNearDone allows for a creation of a custom button near the done/close button.
371
+ * The button is only shown when toolbarType is not "activity", "navigation", or "blank".
372
+ *
373
+ * For Android:
374
+ * - iconType must be "asset"
375
+ * - icon path should be in the public folder (e.g. "monkey.svg")
376
+ * - width and height are optional, defaults to 48dp
377
+ * - button is positioned at the end of toolbar with 8dp margin
378
+ *
379
+ * For iOS:
380
+ * - iconType can be "sf-symbol" or "asset"
381
+ * - for sf-symbol, icon should be the symbol name
382
+ * - for asset, icon should be the asset name
383
+ * @since 6.7.0
384
+ * @example
385
+ * buttonNearDone: {
386
+ * ios: {
387
+ * iconType: "sf-symbol",
388
+ * icon: "star.fill"
389
+ * },
390
+ * android: {
391
+ * iconType: "asset",
392
+ * icon: "public/monkey.svg",
393
+ * width: 24,
394
+ * height: 24
395
+ * }
396
+ * }
397
+ * Test URL: https://capgo.app
398
+ */
399
+ buttonNearDone?: {
400
+ ios: {
401
+ iconType: 'sf-symbol' | 'asset';
402
+ icon: string;
403
+ };
404
+ android: {
405
+ iconType: 'asset' | 'vector';
406
+ icon: string;
407
+ width?: number;
408
+ height?: number;
409
+ };
410
+ };
411
+ /**
412
+ * textZoom: sets the text zoom of the page in percent.
413
+ * Allows users to increase or decrease the text size for better readability.
414
+ * @since 7.6.0
415
+ * @default 100
416
+ * @example
417
+ * textZoom: 120
418
+ * Test URL: https://capgo.app
419
+ */
420
+ textZoom?: number;
421
+ /**
422
+ * 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.
423
+ * @since 0.1.0
424
+ * @default false
425
+ * @example
426
+ * preventDeeplink: true
427
+ * Test URL: https://aasa-tester.capgo.app/
428
+ */
429
+ preventDeeplink?: boolean;
430
+ /**
431
+ * List of base URLs whose hosts are treated as authorized App Links (Android) and Universal Links (iOS).
432
+ *
433
+ * - On both platforms, only HTTPS links whose host matches any entry in this list
434
+ * will attempt to open via the corresponding native application.
435
+ * - If the app is not installed or the system cannot handle the link, the URL
436
+ * will continue loading inside the in-app browser.
437
+ * - Matching is host-based (case-insensitive), ignoring the "www." prefix.
438
+ * - When `preventDeeplink` is enabled, all external handling is blocked regardless of this list.
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * ["https://example.com", "https://subdomain.app.io"]
443
+ * ```
444
+ *
445
+ * @since 7.12.0
446
+ * @default []
447
+ */
448
+ authorizedAppLinks?: string[];
449
+ /**
450
+ * If true, the webView will not take the full height and will have a 20px margin at the bottom.
451
+ * This creates a safe margin area outside the browser view.
452
+ * @since 7.13.0
453
+ * @default false
454
+ * @example
455
+ * enabledSafeBottomMargin: true
456
+ */
457
+ enabledSafeBottomMargin?: boolean;
458
+ /**
459
+ * When true, applies the system status bar inset as the WebView top margin on Android.
460
+ * Keeps the legacy 0px margin by default for apps that handle padding themselves.
461
+ * @default false
462
+ * @example
463
+ * useTopInset: true
464
+ */
465
+ useTopInset?: boolean;
466
+ /**
467
+ * enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API.
468
+ * This fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy.
469
+ * Only enable this if you need Google Pay functionality as it allows popup windows.
470
+ *
471
+ * When enabled:
472
+ * - Allows popup windows for Google Pay authentication
473
+ * - Sets proper CORS headers for Payment Request API
474
+ * - Enables multiple window support in WebView
475
+ * - Configures secure context for payment processing
476
+ *
477
+ * @since 7.13.0
478
+ * @default false
479
+ * @example
480
+ * enableGooglePaySupport: true
481
+ * Test URL: https://developers.google.com/pay/api/web/guides/tutorial
482
+ */
483
+ enableGooglePaySupport?: boolean;
484
+ /**
485
+ * blockedHosts: List of host patterns that should be blocked from loading in the InAppBrowser's internal navigations.
486
+ * Any request inside WebView to a URL with a host matching any of these patterns will be blocked.
487
+ * Supports wildcard patterns like:
488
+ * - "*.example.com" to block all subdomains
489
+ * - "www.example.*" to block wildcard domain extensions
490
+ *
491
+ * @since 7.17.0
492
+ * @default []
493
+ * @example
494
+ * blockedHosts: ["*.tracking.com", "ads.example.com"]
495
+ */
496
+ blockedHosts?: string[];
497
+ /**
498
+ * Width of the webview in pixels.
499
+ * If not set, webview will be fullscreen width.
500
+ * @default undefined (fullscreen)
501
+ * @example
502
+ * width: 400
503
+ */
504
+ width?: number;
505
+ /**
506
+ * Height of the webview in pixels.
507
+ * If not set, webview will be fullscreen height.
508
+ * @default undefined (fullscreen)
509
+ * @example
510
+ * height: 600
511
+ */
512
+ height?: number;
513
+ /**
514
+ * X position of the webview in pixels from the left edge.
515
+ * Only effective when width is set.
516
+ * @default 0
517
+ * @example
518
+ * x: 50
519
+ */
520
+ x?: number;
521
+ /**
522
+ * Y position of the webview in pixels from the top edge.
523
+ * Only effective when height is set.
524
+ * @default 0
525
+ * @example
526
+ * y: 100
527
+ */
528
+ y?: number;
529
+ }
530
+ export interface DimensionOptions {
531
+ /**
532
+ * Width of the webview in pixels
533
+ */
534
+ width?: number;
535
+ /**
536
+ * Height of the webview in pixels
537
+ */
538
+ height?: number;
539
+ /**
540
+ * X position from the left edge in pixels
541
+ */
542
+ x?: number;
543
+ /**
544
+ * Y position from the top edge in pixels
545
+ */
546
+ y?: number;
104
547
  }
105
548
  export interface InAppBrowserPlugin {
106
549
  /**
107
- * Open url in a new window fullscreen
550
+ * Navigates back in the WebView's history if possible
551
+ *
552
+ * @since 7.21.0
553
+ * @returns Promise that resolves with true if navigation was possible, false otherwise
554
+ */
555
+ goBack(): Promise<{
556
+ canGoBack: boolean;
557
+ }>;
558
+ /**
559
+ * Open url in a new window fullscreen, on android it use chrome custom tabs, on ios it use SFSafariViewController
108
560
  *
109
561
  * @since 0.1.0
110
562
  */
111
563
  open(options: OpenOptions): Promise<any>;
112
564
  /**
113
- * Clear all cookies
565
+ * Clear cookies of url
114
566
  *
115
567
  * @since 0.5.0
116
568
  */
117
- clearCookies(): Promise<any>;
118
- close(): Promise<any>;
569
+ clearCookies(options: ClearCookieOptions): Promise<any>;
570
+ /**
571
+ * Clear all cookies
572
+ *
573
+ * @since 6.5.0
574
+ */
575
+ clearAllCookies(): Promise<any>;
576
+ /**
577
+ * Clear cache
578
+ *
579
+ * @since 6.5.0
580
+ */
581
+ clearCache(): Promise<any>;
582
+ /**
583
+ * Get cookies for a specific URL.
584
+ * @param options The options, including the URL to get cookies for.
585
+ * @returns A promise that resolves with the cookies.
586
+ */
587
+ getCookies(options: GetCookieOptions): Promise<Record<string, string>>;
588
+ /**
589
+ * Close the webview.
590
+ */
591
+ close(options?: CloseWebviewOptions): Promise<any>;
119
592
  /**
120
- * Open url in a new webview with toolbars
593
+ * Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.
594
+ *
595
+ * JavaScript Interface:
596
+ * When you open a webview with this method, a JavaScript interface is automatically injected that provides:
597
+ * - `window.mobileApp.close()`: Closes the webview from JavaScript
598
+ * - `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
121
599
  *
122
600
  * @since 0.1.0
123
601
  */
124
602
  openWebView(options: OpenWebViewOptions): Promise<any>;
603
+ /**
604
+ * Injects JavaScript code into the InAppBrowser window.
605
+ */
606
+ executeScript({ code }: {
607
+ code: string;
608
+ }): Promise<void>;
609
+ /**
610
+ * Sends an event to the webview(inappbrowser). you can listen to this event in the inappbrowser JS with window.addEventListener("messageFromNative", listenerFunc: (event: Record<string, any>) => void)
611
+ * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects
612
+ * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.
613
+ */
614
+ postMessage(options: {
615
+ detail: Record<string, any>;
616
+ }): Promise<void>;
617
+ /**
618
+ * Sets the URL of the webview.
619
+ */
125
620
  setUrl(options: {
126
621
  url: string;
127
622
  }): Promise<any>;
128
623
  /**
129
- * Listen for url change
624
+ * Listen for url change, only for openWebView
130
625
  *
131
626
  * @since 0.0.1
132
627
  */
133
- addListener(eventName: "urlChangeEvent", listenerFunc: UrlChangeListener): Promise<PluginListenerHandle> & PluginListenerHandle;
628
+ addListener(eventName: 'urlChangeEvent', listenerFunc: UrlChangeListener): Promise<PluginListenerHandle>;
629
+ addListener(eventName: 'buttonNearDoneClick', listenerFunc: ButtonNearListener): Promise<PluginListenerHandle>;
134
630
  /**
135
- * Listen for close click
631
+ * Listen for close click only for openWebView
136
632
  *
137
633
  * @since 0.4.0
138
634
  */
139
- addListener(eventName: "closeEvent", listenerFunc: UrlChangeListener): Promise<PluginListenerHandle> & PluginListenerHandle;
635
+ addListener(eventName: 'closeEvent', listenerFunc: UrlChangeListener): Promise<PluginListenerHandle>;
140
636
  /**
141
- * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS
637
+ * Will be triggered when user clicks on confirm button when disclaimer is required,
638
+ * works with openWebView shareDisclaimer and closeModal
142
639
  *
143
640
  * @since 0.0.1
144
641
  */
145
- addListener(eventName: "confirmBtnClicked", listenerFunc: ConfirmBtnListener): Promise<PluginListenerHandle> & PluginListenerHandle;
642
+ addListener(eventName: 'confirmBtnClicked', listenerFunc: ConfirmBtnListener): Promise<PluginListenerHandle>;
643
+ /**
644
+ * 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" } })
645
+ * detail is the data you want to send to the main app, it's a requirement of Capacitor we cannot send direct objects
646
+ * Your object has to be serializable to JSON, no functions or other non-JSON-serializable types are allowed.
647
+ *
648
+ * This method is inject at runtime in the webview
649
+ */
650
+ addListener(eventName: 'messageFromWebview', listenerFunc: (event: {
651
+ detail: Record<string, any>;
652
+ }) => void): Promise<PluginListenerHandle>;
653
+ /**
654
+ * Will be triggered when page is loaded
655
+ */
656
+ addListener(eventName: 'browserPageLoaded', listenerFunc: () => void): Promise<PluginListenerHandle>;
657
+ /**
658
+ * Will be triggered when page load error
659
+ */
660
+ addListener(eventName: 'pageLoadError', listenerFunc: () => void): Promise<PluginListenerHandle>;
146
661
  /**
147
662
  * Remove all listeners for this plugin.
148
663
  *
149
664
  * @since 1.0.0
150
665
  */
151
666
  removeAllListeners(): Promise<void>;
667
+ /**
668
+ * Reload the current web page.
669
+ *
670
+ * @since 1.0.0
671
+ */
672
+ reload(): Promise<any>;
673
+ /**
674
+ * Update the dimensions of the webview.
675
+ * Allows changing the size and position of the webview at runtime.
676
+ *
677
+ * @param options Dimension options (width, height, x, y)
678
+ * @returns Promise that resolves when dimensions are updated
679
+ */
680
+ updateDimensions(options: DimensionOptions): Promise<void>;
681
+ }
682
+ /**
683
+ * JavaScript APIs available in the InAppBrowser WebView.
684
+ *
685
+ * These APIs are automatically injected into all webpages loaded in the InAppBrowser WebView.
686
+ *
687
+ * @example
688
+ * // Closing the webview from JavaScript
689
+ * window.mobileApp.close();
690
+ *
691
+ * // Sending a message from webview to the native app
692
+ * window.mobileApp.postMessage({ key: "value" });
693
+ *
694
+ * @since 6.10.0
695
+ */
696
+ export interface InAppBrowserWebViewAPIs {
697
+ /**
698
+ * mobileApp - Global object injected into the WebView providing communication with the native app
699
+ */
700
+ mobileApp: {
701
+ /**
702
+ * Close the WebView from JavaScript
703
+ *
704
+ * @example
705
+ * // Add a button to close the webview
706
+ * const closeButton = document.createElement("button");
707
+ * closeButton.textContent = "Close WebView";
708
+ * closeButton.addEventListener("click", () => {
709
+ * window.mobileApp.close();
710
+ * });
711
+ * document.body.appendChild(closeButton);
712
+ *
713
+ * @since 6.10.0
714
+ */
715
+ close(): void;
716
+ /**
717
+ * Send a message from the WebView to the native app
718
+ * The native app can listen for these messages with the "messageFromWebview" event
719
+ *
720
+ * @param message Object to send to the native app
721
+ * @example
722
+ * // Send data to native app
723
+ * window.mobileApp.postMessage({
724
+ * action: "dataSubmitted",
725
+ * data: { username: "test", email: "test@example.com" }
726
+ * });
727
+ *
728
+ * @since 6.10.0
729
+ */
730
+ postMessage(message: Record<string, any>): void;
731
+ };
732
+ /**
733
+ * Get the native Capacitor plugin version
734
+ *
735
+ * @returns {Promise<{ id: string }>} an Promise with version for this device
736
+ * @throws An error if the something went wrong
737
+ */
738
+ getPluginVersion(): Promise<{
739
+ version: string;
740
+ }>;
152
741
  }