@capgo/inappbrowser 6.0.8 → 6.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -325,6 +325,7 @@ Reload the current web page.
325
325
  | **`visibleTitle`** | <code>boolean</code> | visibleTitle: if true the website title would be shown else shown empty | <code>true</code> | 1.2.5 |
326
326
  | **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>'#ffffff''</code> | 1.2.5 |
327
327
  | **`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 |
328
+ | **`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 |
328
329
 
329
330
 
330
331
  #### DisclaimerOptions
@@ -7,4 +7,6 @@
7
7
  <data android:scheme="http" />
8
8
  </intent>
9
9
  </queries>
10
- </manifest>
10
+ <uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
11
+ <uses-permission android:name="android.permission.CAMERA"/>
12
+ </manifest>
@@ -1,6 +1,7 @@
1
1
  package ee.forgr.capacitor_inappbrowser;
2
2
 
3
3
  import android.Manifest;
4
+ import android.app.Activity;
4
5
  import android.content.ComponentName;
5
6
  import android.content.Intent;
6
7
  import android.content.pm.PackageManager;
@@ -21,6 +22,7 @@ import com.getcapacitor.PermissionState;
21
22
  import com.getcapacitor.Plugin;
22
23
  import com.getcapacitor.PluginCall;
23
24
  import com.getcapacitor.PluginMethod;
25
+ import com.getcapacitor.annotation.ActivityCallback;
24
26
  import com.getcapacitor.annotation.CapacitorPlugin;
25
27
  import com.getcapacitor.annotation.Permission;
26
28
  import com.getcapacitor.annotation.PermissionCallback;
@@ -30,7 +32,16 @@ import java.util.Iterator;
30
32
  name = "InAppBrowser",
31
33
  permissions = {
32
34
  @Permission(alias = "camera", strings = { Manifest.permission.CAMERA }),
33
- }
35
+ @Permission(
36
+ alias = "storage",
37
+ strings = { Manifest.permission.READ_EXTERNAL_STORAGE }
38
+ ),
39
+ @Permission(
40
+ alias = "storage",
41
+ strings = { Manifest.permission.READ_MEDIA_IMAGES }
42
+ ),
43
+ },
44
+ requestCodes = { WebViewDialog.FILE_CHOOSER_REQUEST_CODE }
34
45
  )
35
46
  public class InAppBrowserPlugin
36
47
  extends Plugin
@@ -53,6 +64,36 @@ public class InAppBrowserPlugin
53
64
  }
54
65
  }
55
66
 
67
+ @Override
68
+ protected void handleOnActivityResult(
69
+ int requestCode,
70
+ int resultCode,
71
+ Intent data
72
+ ) {
73
+ super.handleOnActivityResult(requestCode, resultCode, data);
74
+
75
+ // Check if the request code matches the file chooser request code
76
+ if (requestCode == WebViewDialog.FILE_CHOOSER_REQUEST_CODE) {
77
+ if (webViewDialog != null && webViewDialog.mFilePathCallback != null) {
78
+ Uri[] results = null;
79
+
80
+ if (resultCode == Activity.RESULT_OK) {
81
+ if (data != null) {
82
+ results = new Uri[] { data.getData() };
83
+ }
84
+ }
85
+
86
+ // Pass the results back to the WebView
87
+ try {
88
+ webViewDialog.mFilePathCallback.onReceiveValue(results);
89
+ webViewDialog.mFilePathCallback = null;
90
+ } catch (Exception e) {
91
+ Log.e("ACTIVITYRESULT", e.getMessage());
92
+ }
93
+ }
94
+ }
95
+ }
96
+
56
97
  @PermissionCallback
57
98
  private void cameraPermissionCallback() {
58
99
  if (getPermissionState("camera") == PermissionState.GRANTED) {
@@ -245,14 +286,17 @@ public class InAppBrowserPlugin
245
286
  options.setUrl(url);
246
287
  options.setHeaders(call.getObject("headers"));
247
288
  options.setShowReloadButton(call.getBoolean("showReloadButton", false));
248
- if (Boolean.TRUE.equals(call.getBoolean("visibleTitle", true))) {
289
+ options.setVisibleTitle(call.getBoolean("visibleTitle", true));
290
+ if (Boolean.TRUE.equals(options.getVisibleTitle())) {
249
291
  options.setTitle(call.getString("title", "New Window"));
250
292
  } else {
251
293
  options.setTitle(call.getString("title", ""));
252
294
  }
253
295
  options.setToolbarColor(call.getString("toolbarColor", "#ffffff"));
254
296
  options.setArrow(Boolean.TRUE.equals(call.getBoolean("showArrow", false)));
255
-
297
+ options.setIgnoreUntrustedSSLError(
298
+ Boolean.TRUE.equals(call.getBoolean("ignoreUntrustedSSLError", false))
299
+ );
256
300
  options.setShareDisclaimer(call.getObject("shareDisclaimer", null));
257
301
  options.setShareSubject(call.getString("shareSubject", null));
258
302
  options.setToolbarType(call.getString("toolbarType", ""));
@@ -24,6 +24,7 @@ public class Options {
24
24
  private boolean VisibleTitle;
25
25
  private String ToolbarColor;
26
26
  private boolean ShowArrow;
27
+ private boolean ignoreUntrustedSSLError;
27
28
 
28
29
  public PluginCall getPluginCall() {
29
30
  return pluginCall;
@@ -190,4 +191,12 @@ public class Options {
190
191
  public void setArrow(boolean _showArrow) {
191
192
  this.ShowArrow = _showArrow;
192
193
  }
194
+
195
+ public boolean ignoreUntrustedSSLError() {
196
+ return ignoreUntrustedSSLError;
197
+ }
198
+
199
+ public void setIgnoreUntrustedSSLError(boolean _ignoreUntrustedSSLError) {
200
+ this.ignoreUntrustedSSLError = _ignoreUntrustedSSLError;
201
+ }
193
202
  }
@@ -1,5 +1,6 @@
1
1
  package ee.forgr.capacitor_inappbrowser;
2
2
 
3
+ import android.annotation.SuppressLint;
3
4
  import android.app.Activity;
4
5
  import android.app.AlertDialog;
5
6
  import android.app.Dialog;
@@ -10,12 +11,15 @@ import android.content.Intent;
10
11
  import android.graphics.Bitmap;
11
12
  import android.graphics.Color;
12
13
  import android.net.Uri;
14
+ import android.net.http.SslError;
13
15
  import android.text.TextUtils;
14
16
  import android.util.Log;
15
17
  import android.view.View;
16
18
  import android.view.Window;
17
19
  import android.view.WindowManager;
18
20
  import android.webkit.PermissionRequest;
21
+ import android.webkit.SslErrorHandler;
22
+ import android.webkit.ValueCallback;
19
23
  import android.webkit.WebChromeClient;
20
24
  import android.webkit.WebResourceError;
21
25
  import android.webkit.WebResourceRequest;
@@ -41,6 +45,9 @@ public class WebViewDialog extends Dialog {
41
45
  private boolean isInitialized = false;
42
46
 
43
47
  public PermissionRequest currentPermissionRequest;
48
+ public static final int FILE_CHOOSER_REQUEST_CODE = 1000;
49
+ public ValueCallback<Uri> mUploadMessage;
50
+ public ValueCallback<Uri[]> mFilePathCallback;
44
51
 
45
52
  public interface PermissionHandler {
46
53
  void handleCameraPermissionRequest(PermissionRequest request);
@@ -95,8 +102,21 @@ public class WebViewDialog extends Dialog {
95
102
 
96
103
  _webView.setWebChromeClient(
97
104
  new WebChromeClient() {
98
- // Grant permissions for cam
105
+ // Enable file open dialog
106
+ @Override
107
+ public boolean onShowFileChooser(
108
+ WebView webView,
109
+ ValueCallback<Uri[]> filePathCallback,
110
+ WebChromeClient.FileChooserParams fileChooserParams
111
+ ) {
112
+ openFileChooser(
113
+ filePathCallback,
114
+ fileChooserParams.getAcceptTypes()[0]
115
+ );
116
+ return true;
117
+ }
99
118
 
119
+ // Grant permissions for cam
100
120
  @Override
101
121
  public void onPermissionRequest(final PermissionRequest request) {
102
122
  Log.i(
@@ -164,6 +184,20 @@ public class WebViewDialog extends Dialog {
164
184
  }
165
185
  }
166
186
 
187
+ private void openFileChooser(
188
+ ValueCallback<Uri[]> filePathCallback,
189
+ String acceptType
190
+ ) {
191
+ mFilePathCallback = filePathCallback;
192
+ Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
193
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
194
+ intent.setType(acceptType); // Default to */*
195
+ activity.startActivityForResult(
196
+ Intent.createChooser(intent, "Select File"),
197
+ FILE_CHOOSER_REQUEST_CODE
198
+ );
199
+ }
200
+
167
201
  public void reload() {
168
202
  _webView.reload();
169
203
  }
@@ -353,7 +387,9 @@ public class WebViewDialog extends Dialog {
353
387
  super.onPageStarted(view, url, favicon);
354
388
  try {
355
389
  URI uri = new URI(url);
356
- setTitle(uri.getHost());
390
+ if (TextUtils.isEmpty(_options.getTitle())) {
391
+ setTitle(uri.getHost());
392
+ }
357
393
  } catch (URISyntaxException e) {
358
394
  // Do nothing
359
395
  }
@@ -413,6 +449,23 @@ public class WebViewDialog extends Dialog {
413
449
  super.onReceivedError(view, request, error);
414
450
  _options.getCallbacks().pageLoadError();
415
451
  }
452
+
453
+ @SuppressLint("WebViewClientOnReceivedSslError")
454
+ @Override
455
+ public void onReceivedSslError(
456
+ WebView view,
457
+ SslErrorHandler handler,
458
+ SslError error
459
+ ) {
460
+ boolean ignoreSSLUntrustedError = _options.ignoreUntrustedSSLError();
461
+ if (
462
+ ignoreSSLUntrustedError &&
463
+ error.getPrimaryError() == SslError.SSL_UNTRUSTED
464
+ ) handler.proceed();
465
+ else {
466
+ super.onReceivedSslError(view, handler, error);
467
+ }
468
+ }
416
469
  }
417
470
  );
418
471
  }
package/dist/docs.json CHANGED
@@ -721,6 +721,22 @@
721
721
  "docs": "showArrow: if true an arrow would be shown instead of cross for closing the window",
722
722
  "complexTypes": [],
723
723
  "type": "boolean | undefined"
724
+ },
725
+ {
726
+ "name": "ignoreUntrustedSSLError",
727
+ "tags": [
728
+ {
729
+ "text": "6.1.0",
730
+ "name": "since"
731
+ },
732
+ {
733
+ "text": "false",
734
+ "name": "default"
735
+ }
736
+ ],
737
+ "docs": "ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.",
738
+ "complexTypes": [],
739
+ "type": "boolean | undefined"
724
740
  }
725
741
  ]
726
742
  },
@@ -196,6 +196,13 @@ export interface OpenWebViewOptions {
196
196
  * @default false
197
197
  */
198
198
  showArrow?: boolean;
199
+ /**
200
+ * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.
201
+ *
202
+ * @since 6.1.0
203
+ * @default false
204
+ */
205
+ ignoreUntrustedSSLError?: boolean;
199
206
  }
200
207
  export interface InAppBrowserPlugin {
201
208
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n cache?: boolean;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title?: string;\n /**\n * Background color of the browser, only on IOS\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * If true, active the native navigation within the webview, Android only\n *\n * @default false\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * usefull to force user to stay on the webview, Android only\n *\n * @default false\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\n *\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n *\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\n *\n * @default true\n */\n isAnimated?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n *\n * @since 1.1.0\n * @default false\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n *\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n *\n * @since 1.2.5\n * @default '#ffffff''\n */\n toolbarColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n *\n * @since 1.2.5\n * @default false\n */\n showArrow?: boolean;\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear cookies of url\n *\n * @since 0.5.0\n */\n clearCookies(options: ClearCookieOptions): Promise<any>;\n\n /**\n * Get cookies for a specific URL.\n * @param options The options, including the URL to get cookies for.\n * @returns A promise that resolves with the cookies.\n */\n getCookies(options: GetCookieOptions): Promise<Record<string, string>>;\n\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Reload the current web page.\n *\n * @since 1.0.0\n */\n reload(): Promise<any>; // Add this line\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n cache?: boolean;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title?: string;\n /**\n * Background color of the browser, only on IOS\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * If true, active the native navigation within the webview, Android only\n *\n * @default false\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * usefull to force user to stay on the webview, Android only\n *\n * @default false\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\n *\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n *\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\n *\n * @default true\n */\n isAnimated?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n *\n * @since 1.1.0\n * @default false\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n *\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n *\n * @since 1.2.5\n * @default '#ffffff''\n */\n toolbarColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n *\n * @since 1.2.5\n * @default false\n */\n showArrow?: boolean;\n /**\n * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\n *\n * @since 6.1.0\n * @default false\n */\n ignoreUntrustedSSLError?: boolean;\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear cookies of url\n *\n * @since 0.5.0\n */\n clearCookies(options: ClearCookieOptions): Promise<any>;\n\n /**\n * Get cookies for a specific URL.\n * @param options The options, including the URL to get cookies for.\n * @returns A promise that resolves with the cookies.\n */\n getCookies(options: GetCookieOptions): Promise<Record<string, string>>;\n\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Reload the current web page.\n *\n * @since 1.0.0\n */\n reload(): Promise<any>; // Add this line\n}\n"]}
@@ -127,6 +127,7 @@ public class InAppBrowserPlugin: CAPPlugin {
127
127
  if toolbarType != "activity" {
128
128
  disclaimerContent = nil
129
129
  }
130
+ let ignoreUntrustedSSLError = call.getBool("ignoreUntrustedSSLError", false)
130
131
 
131
132
  self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
132
133
  let showReloadButton = call.getBool("showReloadButton", false)
@@ -162,6 +163,7 @@ public class InAppBrowserPlugin: CAPPlugin {
162
163
  self.webViewController?.closeModalOk = closeModalOk
163
164
  self.webViewController?.closeModalCancel = closeModalCancel
164
165
  }
166
+ self.webViewController?.ignoreUntrustedSSLError = ignoreUntrustedSSLError
165
167
  self.navigationWebViewController = UINavigationController.init(rootViewController: self.webViewController!)
166
168
  self.navigationWebViewController?.navigationBar.isTranslucent = false
167
169
  self.navigationWebViewController?.toolbar.isTranslucent = false
@@ -89,6 +89,7 @@ open class WKWebViewController: UIViewController {
89
89
  open var closeModalDescription = ""
90
90
  open var closeModalOk = ""
91
91
  open var closeModalCancel = ""
92
+ open var ignoreUntrustedSSLError = false
92
93
 
93
94
  func setHeaders(headers: [String: String]) {
94
95
  self.headers = headers
@@ -780,7 +781,20 @@ extension WKWebViewController: WKNavigationDelegate {
780
781
  let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!)
781
782
  completionHandler(.useCredential, credential)
782
783
  } else {
783
- completionHandler(.performDefaultHandling, nil)
784
+ guard self.ignoreUntrustedSSLError else {
785
+ completionHandler(.performDefaultHandling, nil)
786
+ return
787
+ }
788
+ /* allows to open links with self-signed certificates
789
+ Follow Apple's guidelines https://developer.apple.com/documentation/foundation/url_loading_system/handling_an_authentication_challenge/performing_manual_server_trust_authentication
790
+ */
791
+ guard let serverTrust = challenge.protectionSpace.serverTrust else {
792
+ completionHandler(.useCredential, nil)
793
+ return
794
+ }
795
+ let credential = URLCredential(trust: serverTrust)
796
+ completionHandler(.useCredential, credential)
797
+
784
798
  }
785
799
  }
786
800
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "6.0.8",
3
+ "version": "6.0.10",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",