@capgo/inappbrowser 6.9.38 → 6.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -99
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +34 -2
- package/dist/docs.json +9 -636
- package/dist/esm/definitions.d.ts +9 -9
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +26 -6
- package/ios/Plugin/WKWebViewController.swift +48 -7
- package/package.json +1 -1
- package/ios/Plugin/InAppBrowserPlugin.h +0 -10
- package/ios/Plugin/InAppBrowserPlugin.m +0 -21
package/README.md
CHANGED
|
@@ -239,7 +239,7 @@ Injects JavaScript code into the InAppBrowser window.
|
|
|
239
239
|
postMessage(options: { detail: Record<string, any>; }) => Promise<void>
|
|
240
240
|
```
|
|
241
241
|
|
|
242
|
-
Sends an event to the webview. you can listen to this event with addListener("
|
|
242
|
+
Sends an event to the webview(inappbrowser). you can listen to this event in the inappbrowser JS with window.addListener("messageFromNative", listenerFunc: (event: <a href="#record">Record</a><string, any>) => void)
|
|
243
243
|
detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects
|
|
244
244
|
Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.
|
|
245
245
|
|
|
@@ -349,9 +349,9 @@ Will be triggered when user clicks on confirm button when disclaimer is required
|
|
|
349
349
|
addListener(eventName: "messageFromWebview", listenerFunc: (event: { detail: Record<string, any>; }) => void) => Promise<PluginListenerHandle>
|
|
350
350
|
```
|
|
351
351
|
|
|
352
|
-
Will be triggered when event is sent from webview, to send an event to the
|
|
353
|
-
detail is the data you want to send to the
|
|
354
|
-
Your object has to be serializable to JSON,
|
|
352
|
+
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" } })
|
|
353
|
+
detail is the data you want to send to the main app, it's a requirement of Capacitor we cannot send direct objects
|
|
354
|
+
Your object has to be serializable to JSON, no functions or other non-JSON-serializable types are allowed.
|
|
355
355
|
|
|
356
356
|
This method is inject at runtime in the webview
|
|
357
357
|
|
|
@@ -480,34 +480,34 @@ Reload the current web page.
|
|
|
480
480
|
|
|
481
481
|
#### OpenWebViewOptions
|
|
482
482
|
|
|
483
|
-
| Prop | Type
|
|
484
|
-
| -------------------------------------- |
|
|
485
|
-
| **`url`** | <code>string</code>
|
|
486
|
-
| **`headers`** | <code><a href="#headers">Headers</a></code>
|
|
487
|
-
| **`credentials`** | <code><a href="#credentials">Credentials</a></code>
|
|
488
|
-
| **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code>
|
|
489
|
-
| **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code>
|
|
490
|
-
| **`shareSubject`** | <code>string</code>
|
|
491
|
-
| **`title`** | <code>string</code>
|
|
492
|
-
| **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code>
|
|
493
|
-
| **`activeNativeNavigationForWebview`** | <code>boolean</code>
|
|
494
|
-
| **`disableGoBackOnNativeApplication`** | <code>boolean</code>
|
|
495
|
-
| **`isPresentAfterPageLoad`** | <code>boolean</code>
|
|
496
|
-
| **`isInspectable`** | <code>boolean</code>
|
|
497
|
-
| **`isAnimated`** | <code>boolean</code>
|
|
498
|
-
| **`showReloadButton`** | <code>boolean</code>
|
|
499
|
-
| **`closeModal`** | <code>boolean</code>
|
|
500
|
-
| **`closeModalTitle`** | <code>string</code>
|
|
501
|
-
| **`closeModalDescription`** | <code>string</code>
|
|
502
|
-
| **`closeModalOk`** | <code>string</code>
|
|
503
|
-
| **`closeModalCancel`** | <code>string</code>
|
|
504
|
-
| **`visibleTitle`** | <code>boolean</code>
|
|
505
|
-
| **`toolbarColor`** | <code>string</code>
|
|
506
|
-
| **`showArrow`** | <code>boolean</code>
|
|
507
|
-
| **`ignoreUntrustedSSLError`** | <code>boolean</code>
|
|
508
|
-
| **`preShowScript`** | <code
|
|
509
|
-
| **`proxyRequests`** | <code
|
|
510
|
-
| **`buttonNearDone`** | <code>{ ios: { iconType: 'sf-symbol' \| 'asset'; icon:
|
|
483
|
+
| Prop | Type | Description | Default | Since |
|
|
484
|
+
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------ |
|
|
485
|
+
| **`url`** | <code>string</code> | Target URL to load. | | 0.1.0 |
|
|
486
|
+
| **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | | 0.1.0 |
|
|
487
|
+
| **`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 |
|
|
488
|
+
| **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | share options | | 0.1.0 |
|
|
489
|
+
| **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type | <code>ToolBarType.DEFAULT</code> | 0.1.0 |
|
|
490
|
+
| **`shareSubject`** | <code>string</code> | Share subject | | 0.1.0 |
|
|
491
|
+
| **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
|
|
492
|
+
| **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser, only on IOS | <code>BackgroundColor.BLACK</code> | 0.1.0 |
|
|
493
|
+
| **`activeNativeNavigationForWebview`** | <code>boolean</code> | If true, active the native navigation within the webview, Android only | <code>false</code> | |
|
|
494
|
+
| **`disableGoBackOnNativeApplication`** | <code>boolean</code> | Disable the possibility to go back on native application, usefull to force user to stay on the webview, Android only | <code>false</code> | |
|
|
495
|
+
| **`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 |
|
|
496
|
+
| **`isInspectable`** | <code>boolean</code> | Whether the website in the webview is inspectable or not, ios only | <code>false</code> | |
|
|
497
|
+
| **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
|
|
498
|
+
| **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
|
|
499
|
+
| **`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 |
|
|
500
|
+
| **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
|
|
501
|
+
| **`closeModalDescription`** | <code>string</code> | CloseModalDescription: description of the confirm when user clicks on close button, only on IOS | <code>'Are you sure you want to close this window?'</code> | 1.1.0 |
|
|
502
|
+
| **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
|
|
503
|
+
| **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS | <code>'Cancel'</code> | 1.1.0 |
|
|
504
|
+
| **`visibleTitle`** | <code>boolean</code> | visibleTitle: if true the website title would be shown else shown empty | <code>true</code> | 1.2.5 |
|
|
505
|
+
| **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>'#ffffff''</code> | 1.2.5 |
|
|
506
|
+
| **`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 |
|
|
507
|
+
| **`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 |
|
|
508
|
+
| **`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 |
|
|
509
|
+
| **`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 |
|
|
510
|
+
| **`buttonNearDone`** | <code>{ ios: { iconType: 'sf-symbol' \| 'asset'; icon: string; }; android: { iconType: 'asset'; icon: string; width?: number; height?: number; }; }</code> | buttonNearDone allows for a creation of a custom button. Please see [buttonNearDone.md](/buttonNearDone.md) for more info. | | 6.7.0 |
|
|
511
511
|
|
|
512
512
|
|
|
513
513
|
#### DisclaimerOptions
|
|
@@ -520,72 +520,6 @@ Reload the current web page.
|
|
|
520
520
|
| **`cancelBtn`** | <code>string</code> |
|
|
521
521
|
|
|
522
522
|
|
|
523
|
-
#### String
|
|
524
|
-
|
|
525
|
-
Allows manipulation and formatting of text strings and determination and location of substrings within strings.
|
|
526
|
-
|
|
527
|
-
| Prop | Type | Description |
|
|
528
|
-
| ------------ | ------------------- | ------------------------------------------------------------ |
|
|
529
|
-
| **`length`** | <code>number</code> | Returns the length of a <a href="#string">String</a> object. |
|
|
530
|
-
|
|
531
|
-
| Method | Signature | Description |
|
|
532
|
-
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
533
|
-
| **toString** | () => string | Returns a string representation of a string. |
|
|
534
|
-
| **charAt** | (pos: number) => string | Returns the character at the specified index. |
|
|
535
|
-
| **charCodeAt** | (index: number) => number | Returns the Unicode value of the character at the specified location. |
|
|
536
|
-
| **concat** | (...strings: string[]) => string | Returns a string that contains the concatenation of two or more strings. |
|
|
537
|
-
| **indexOf** | (searchString: string, position?: number \| undefined) => number | Returns the position of the first occurrence of a substring. |
|
|
538
|
-
| **lastIndexOf** | (searchString: string, position?: number \| undefined) => number | Returns the last occurrence of a substring in the string. |
|
|
539
|
-
| **localeCompare** | (that: string) => number | Determines whether two strings are equivalent in the current locale. |
|
|
540
|
-
| **match** | (regexp: string \| <a href="#regexp">RegExp</a>) => <a href="#regexpmatcharray">RegExpMatchArray</a> \| null | Matches a string with a regular expression, and returns an array containing the results of that search. |
|
|
541
|
-
| **replace** | (searchValue: string \| <a href="#regexp">RegExp</a>, replaceValue: string) => string | Replaces text in a string, using a regular expression or search string. |
|
|
542
|
-
| **replace** | (searchValue: string \| <a href="#regexp">RegExp</a>, replacer: (substring: string, ...args: any[]) => string) => string | Replaces text in a string, using a regular expression or search string. |
|
|
543
|
-
| **search** | (regexp: string \| <a href="#regexp">RegExp</a>) => number | Finds the first substring match in a regular expression search. |
|
|
544
|
-
| **slice** | (start?: number \| undefined, end?: number \| undefined) => string | Returns a section of a string. |
|
|
545
|
-
| **split** | (separator: string \| <a href="#regexp">RegExp</a>, limit?: number \| undefined) => string[] | Split a string into substrings using the specified separator and return them as an array. |
|
|
546
|
-
| **substring** | (start: number, end?: number \| undefined) => string | Returns the substring at the specified location within a <a href="#string">String</a> object. |
|
|
547
|
-
| **toLowerCase** | () => string | Converts all the alphabetic characters in a string to lowercase. |
|
|
548
|
-
| **toLocaleLowerCase** | (locales?: string \| string[] \| undefined) => string | Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. |
|
|
549
|
-
| **toUpperCase** | () => string | Converts all the alphabetic characters in a string to uppercase. |
|
|
550
|
-
| **toLocaleUpperCase** | (locales?: string \| string[] \| undefined) => string | Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. |
|
|
551
|
-
| **trim** | () => string | Removes the leading and trailing white space and line terminator characters from a string. |
|
|
552
|
-
| **substr** | (from: number, length?: number \| undefined) => string | Gets a substring beginning at the specified location and having the specified length. |
|
|
553
|
-
| **valueOf** | () => string | Returns the primitive value of the specified object. |
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
#### RegExpMatchArray
|
|
557
|
-
|
|
558
|
-
| Prop | Type |
|
|
559
|
-
| ----------- | ------------------- |
|
|
560
|
-
| **`index`** | <code>number</code> |
|
|
561
|
-
| **`input`** | <code>string</code> |
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
#### RegExp
|
|
565
|
-
|
|
566
|
-
| Prop | Type | Description |
|
|
567
|
-
| ---------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
568
|
-
| **`source`** | <code>string</code> | Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. |
|
|
569
|
-
| **`global`** | <code>boolean</code> | Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. |
|
|
570
|
-
| **`ignoreCase`** | <code>boolean</code> | Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. |
|
|
571
|
-
| **`multiline`** | <code>boolean</code> | Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. |
|
|
572
|
-
| **`lastIndex`** | <code>number</code> | |
|
|
573
|
-
|
|
574
|
-
| Method | Signature | Description |
|
|
575
|
-
| ----------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
576
|
-
| **exec** | (string: string) => <a href="#regexpexecarray">RegExpExecArray</a> \| null | Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. |
|
|
577
|
-
| **test** | (string: string) => boolean | Returns a Boolean value that indicates whether or not a pattern exists in a searched string. |
|
|
578
|
-
| **compile** | () => this | |
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
#### RegExpExecArray
|
|
582
|
-
|
|
583
|
-
| Prop | Type |
|
|
584
|
-
| ----------- | ------------------- |
|
|
585
|
-
| **`index`** | <code>number</code> |
|
|
586
|
-
| **`input`** | <code>string</code> |
|
|
587
|
-
|
|
588
|
-
|
|
589
523
|
#### PluginListenerHandle
|
|
590
524
|
|
|
591
525
|
| Prop | Type |
|
|
@@ -655,7 +589,7 @@ Construct a type with a set of properties K of type T
|
|
|
655
589
|
|
|
656
590
|
#### ButtonNearListener
|
|
657
591
|
|
|
658
|
-
<code>(state:
|
|
592
|
+
<code>(state: object): void</code>
|
|
659
593
|
|
|
660
594
|
|
|
661
595
|
#### ConfirmBtnListener
|
|
@@ -38,6 +38,7 @@ import android.widget.TextView;
|
|
|
38
38
|
import android.widget.Toast;
|
|
39
39
|
import android.widget.Toolbar;
|
|
40
40
|
import androidx.annotation.RequiresApi;
|
|
41
|
+
import androidx.core.view.WindowInsetsControllerCompat;
|
|
41
42
|
import com.caverock.androidsvg.SVG;
|
|
42
43
|
import com.caverock.androidsvg.SVGParseException;
|
|
43
44
|
import com.getcapacitor.JSObject;
|
|
@@ -132,6 +133,21 @@ public class WebViewDialog extends Dialog {
|
|
|
132
133
|
// Handle message from JavaScript
|
|
133
134
|
_options.getCallbacks().javascriptCallback(message);
|
|
134
135
|
}
|
|
136
|
+
|
|
137
|
+
@JavascriptInterface
|
|
138
|
+
public void close() {
|
|
139
|
+
// close webview
|
|
140
|
+
activity.runOnUiThread(
|
|
141
|
+
new Runnable() {
|
|
142
|
+
@Override
|
|
143
|
+
public void run() {
|
|
144
|
+
dismiss();
|
|
145
|
+
_options.getCallbacks().closeEvent(_webView.getUrl());
|
|
146
|
+
_webView.destroy();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
135
151
|
}
|
|
136
152
|
|
|
137
153
|
public class PreShowScriptInterface {
|
|
@@ -163,6 +179,17 @@ public class WebViewDialog extends Dialog {
|
|
|
163
179
|
WindowManager.LayoutParams.FLAG_FULLSCREEN
|
|
164
180
|
);
|
|
165
181
|
setContentView(R.layout.activity_browser);
|
|
182
|
+
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
183
|
+
|
|
184
|
+
WindowInsetsControllerCompat insetsController =
|
|
185
|
+
new WindowInsetsControllerCompat(getWindow(), getWindow().getDecorView());
|
|
186
|
+
insetsController.setAppearanceLightStatusBars(false);
|
|
187
|
+
getWindow()
|
|
188
|
+
.getDecorView()
|
|
189
|
+
.post(() -> {
|
|
190
|
+
getWindow().setStatusBarColor(Color.BLACK);
|
|
191
|
+
});
|
|
192
|
+
|
|
166
193
|
getWindow()
|
|
167
194
|
.setLayout(
|
|
168
195
|
WindowManager.LayoutParams.MATCH_PARENT,
|
|
@@ -318,6 +345,9 @@ public class WebViewDialog extends Dialog {
|
|
|
318
345
|
" if (window.AndroidInterface) { " +
|
|
319
346
|
" window.AndroidInterface.postMessage(JSON.stringify(message)); " +
|
|
320
347
|
" } " +
|
|
348
|
+
" }, " +
|
|
349
|
+
" close: function() { " +
|
|
350
|
+
" window.AndroidInterface.close(); " +
|
|
321
351
|
" } " +
|
|
322
352
|
" }; " +
|
|
323
353
|
"}";
|
|
@@ -487,7 +517,7 @@ public class WebViewDialog extends Dialog {
|
|
|
487
517
|
}
|
|
488
518
|
);
|
|
489
519
|
|
|
490
|
-
|
|
520
|
+
ImageButton closeButton = _toolbar.findViewById(R.id.closeButton);
|
|
491
521
|
closeButton.setOnClickListener(
|
|
492
522
|
new View.OnClickListener() {
|
|
493
523
|
@Override
|
|
@@ -520,7 +550,7 @@ public class WebViewDialog extends Dialog {
|
|
|
520
550
|
);
|
|
521
551
|
|
|
522
552
|
if (_options.showArrow()) {
|
|
523
|
-
closeButton.
|
|
553
|
+
closeButton.setImageResource(R.drawable.arrow_back_enabled);
|
|
524
554
|
}
|
|
525
555
|
|
|
526
556
|
if (_options.getShowReloadButton()) {
|
|
@@ -1031,6 +1061,8 @@ public class WebViewDialog extends Dialog {
|
|
|
1031
1061
|
) {
|
|
1032
1062
|
_webView.goBack();
|
|
1033
1063
|
} else if (!_options.getDisableGoBackOnNativeApplication()) {
|
|
1064
|
+
_options.getCallbacks().closeEvent(_webView.getUrl());
|
|
1065
|
+
_webView.destroy();
|
|
1034
1066
|
super.onBackPressed();
|
|
1035
1067
|
}
|
|
1036
1068
|
}
|