@capgo/inappbrowser 0.0.3 → 0.0.6
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 +4 -4
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +14 -19
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +1 -3
- package/dist/docs.json +3 -3
- package/dist/esm/definitions.d.ts +3 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -1
- package/dist/esm/web.js +2 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +2 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +27 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,12 +72,12 @@ openWebView(options: OpenWebViewOptions) => Promise<any>
|
|
|
72
72
|
### setUrl(...)
|
|
73
73
|
|
|
74
74
|
```typescript
|
|
75
|
-
setUrl(url: string) => Promise<any>
|
|
75
|
+
setUrl(options: { url: string; }) => Promise<any>
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
| Param
|
|
79
|
-
|
|
|
80
|
-
| **`
|
|
78
|
+
| Param | Type |
|
|
79
|
+
| ------------- | ----------------------------- |
|
|
80
|
+
| **`options`** | <code>{ url: string; }</code> |
|
|
81
81
|
|
|
82
82
|
**Returns:** <code>Promise<any></code>
|
|
83
83
|
|
|
@@ -4,24 +4,25 @@ import android.content.ComponentName;
|
|
|
4
4
|
import android.content.Intent;
|
|
5
5
|
import android.net.Uri;
|
|
6
6
|
import android.os.Bundle;
|
|
7
|
-
import android.support.customtabs.CustomTabsCallback;
|
|
8
|
-
import android.support.customtabs.CustomTabsClient;
|
|
9
|
-
import android.support.customtabs.CustomTabsIntent;
|
|
10
|
-
import android.support.customtabs.CustomTabsServiceConnection;
|
|
11
|
-
import android.support.customtabs.CustomTabsSession;
|
|
12
7
|
import android.text.TextUtils;
|
|
13
8
|
import android.util.Log;
|
|
14
9
|
|
|
10
|
+
import androidx.browser.customtabs.CustomTabsCallback;
|
|
11
|
+
import androidx.browser.customtabs.CustomTabsClient;
|
|
12
|
+
import androidx.browser.customtabs.CustomTabsIntent;
|
|
13
|
+
import androidx.browser.customtabs.CustomTabsServiceConnection;
|
|
14
|
+
import androidx.browser.customtabs.CustomTabsSession;
|
|
15
|
+
|
|
15
16
|
import com.getcapacitor.JSObject;
|
|
16
|
-
import com.getcapacitor.NativePlugin;
|
|
17
17
|
import com.getcapacitor.Plugin;
|
|
18
18
|
import com.getcapacitor.PluginCall;
|
|
19
19
|
import com.getcapacitor.PluginMethod;
|
|
20
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
20
21
|
|
|
21
22
|
import java.util.Iterator;
|
|
22
23
|
|
|
23
|
-
@
|
|
24
|
-
public class
|
|
24
|
+
@CapacitorPlugin(name = "InAppBrowserPlugin")
|
|
25
|
+
public class InAppBrowserPlugin extends Plugin {
|
|
25
26
|
public static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome"; // Change when in stable
|
|
26
27
|
private CustomTabsClient customTabsClient;
|
|
27
28
|
private CustomTabsSession currentSession;
|
|
@@ -41,31 +42,30 @@ public class CapBrowser extends Plugin {
|
|
|
41
42
|
|
|
42
43
|
@PluginMethod()
|
|
43
44
|
public void setUrl(PluginCall call) {
|
|
44
|
-
call.
|
|
45
|
+
call.resolve();
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
@PluginMethod()
|
|
48
49
|
public void open(PluginCall call) {
|
|
49
50
|
String url = call.getString("url");
|
|
50
51
|
if(url == null || TextUtils.isEmpty(url)) {
|
|
51
|
-
call.
|
|
52
|
+
call.reject("Invalid URL");
|
|
52
53
|
}
|
|
53
54
|
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getCustomTabsSession());
|
|
54
|
-
builder.addDefaultShareMenuItem();
|
|
55
55
|
CustomTabsIntent tabsIntent = builder.build();
|
|
56
56
|
tabsIntent.intent.putExtra(Intent.EXTRA_REFERRER,
|
|
57
57
|
Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + getContext().getPackageName()));
|
|
58
58
|
tabsIntent.intent.putExtra(android.provider.Browser.EXTRA_HEADERS, this.getHeaders(call));
|
|
59
59
|
tabsIntent.launchUrl(getContext(), Uri.parse(url));
|
|
60
60
|
|
|
61
|
-
call.
|
|
61
|
+
call.resolve();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
@PluginMethod()
|
|
65
65
|
public void openWebView(PluginCall call) {
|
|
66
66
|
String url = call.getString("url");
|
|
67
67
|
if(url == null || TextUtils.isEmpty(url)) {
|
|
68
|
-
call.
|
|
68
|
+
call.reject("Invalid URL");
|
|
69
69
|
}
|
|
70
70
|
final Options options = new Options();
|
|
71
71
|
options.setUrl(url);
|
|
@@ -111,7 +111,7 @@ public class CapBrowser extends Plugin {
|
|
|
111
111
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
112
112
|
getContext().startActivity(intent);
|
|
113
113
|
}
|
|
114
|
-
call.
|
|
114
|
+
call.resolve();
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
private Bundle getHeaders(PluginCall pluginCall) {
|
|
@@ -157,9 +157,4 @@ public class CapBrowser extends Plugin {
|
|
|
157
157
|
}
|
|
158
158
|
return currentSession;
|
|
159
159
|
}
|
|
160
|
-
|
|
161
|
-
@Override
|
|
162
|
-
protected void handleOnActivityResult(int requestCode, int resultCode, Intent data) {
|
|
163
|
-
super.handleOnActivityResult(requestCode, resultCode, data);
|
|
164
|
-
}
|
|
165
160
|
}
|
|
@@ -3,7 +3,6 @@ package ee.forgr.capacitor_inappbrowser;
|
|
|
3
3
|
import android.app.Dialog;
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.graphics.Bitmap;
|
|
6
|
-
import android.support.v7.widget.Toolbar;
|
|
7
6
|
import android.text.TextUtils;
|
|
8
7
|
import android.view.View;
|
|
9
8
|
import android.view.Window;
|
|
@@ -14,8 +13,7 @@ import android.webkit.WebView;
|
|
|
14
13
|
import android.webkit.WebViewClient;
|
|
15
14
|
import android.widget.ImageButton;
|
|
16
15
|
import android.widget.TextView;
|
|
17
|
-
|
|
18
|
-
import com.cap.browser.plugin.capbrowser.R;
|
|
16
|
+
import android.widget.Toolbar;
|
|
19
17
|
|
|
20
18
|
import java.net.URI;
|
|
21
19
|
import java.net.URISyntaxException;
|
package/dist/docs.json
CHANGED
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"name": "setUrl",
|
|
56
|
-
"signature": "(url: string) => Promise<any>",
|
|
56
|
+
"signature": "(options: { url: string; }) => Promise<any>",
|
|
57
57
|
"parameters": [
|
|
58
58
|
{
|
|
59
|
-
"name": "
|
|
59
|
+
"name": "options",
|
|
60
60
|
"docs": "",
|
|
61
|
-
"type": "string"
|
|
61
|
+
"type": "{ url: string; }"
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
64
|
"returns": "Promise<any>",
|
|
@@ -50,7 +50,9 @@ export interface InAppBrowserPlugin {
|
|
|
50
50
|
open(options: OpenOptions): Promise<any>;
|
|
51
51
|
close(): Promise<any>;
|
|
52
52
|
openWebView(options: OpenWebViewOptions): Promise<any>;
|
|
53
|
-
setUrl(
|
|
53
|
+
setUrl(options: {
|
|
54
|
+
url: string;
|
|
55
|
+
}): Promise<any>;
|
|
54
56
|
/**
|
|
55
57
|
* Listen for url change
|
|
56
58
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,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 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 OpenOptions {\n url: string;\n headers?: Headers;\n isPresentAfterPageLoad?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n url: string;\n headers?: Headers;\n shareDisclaimer?: DisclaimerOptions;\n toolbarType?: ToolBarType;\n shareSubject?: string;\n title: string;\n isPresentAfterPageLoad?: boolean;\n}\n\n// CapBrowser.addListener(\"urlChangeEvent\", (info: any) => {\n// console.log(info.url)\n// })\n\n// CapBrowser.addListener(\"confirmBtnClicked\", (info: any) => {\n// // will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n// console.log(info.url)\n// })\nexport interface InAppBrowserPlugin {\n open(options: OpenOptions): Promise<any>;\n close(): Promise<any>;\n openWebView(options: OpenWebViewOptions): Promise<any>;\n setUrl(url: string): Promise<any>;\n /**\n * Listen for url change \n *\n * @since 0.0.1\n */\n addListener(\n eventName: 'urlChangeEvent',\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle> & 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> & PluginListenerHandle;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,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 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 OpenOptions {\n url: string;\n headers?: Headers;\n isPresentAfterPageLoad?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n url: string;\n headers?: Headers;\n shareDisclaimer?: DisclaimerOptions;\n toolbarType?: ToolBarType;\n shareSubject?: string;\n title: string;\n isPresentAfterPageLoad?: boolean;\n}\n\n// CapBrowser.addListener(\"urlChangeEvent\", (info: any) => {\n// console.log(info.url)\n// })\n\n// CapBrowser.addListener(\"confirmBtnClicked\", (info: any) => {\n// // will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n// console.log(info.url)\n// })\nexport interface InAppBrowserPlugin {\n open(options: OpenOptions): Promise<any>;\n close(): Promise<any>;\n openWebView(options: OpenWebViewOptions): Promise<any>;\n setUrl(options: {url: string}): Promise<any>;\n /**\n * Listen for url change \n *\n * @since 0.0.1\n */\n addListener(\n eventName: 'urlChangeEvent',\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle> & 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> & PluginListenerHandle;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export declare class InAppBrowserWeb extends WebPlugin implements InAppBrowserPl
|
|
|
4
4
|
open(options: OpenOptions): Promise<any>;
|
|
5
5
|
openWebView(options: OpenWebViewOptions): Promise<any>;
|
|
6
6
|
close(): Promise<any>;
|
|
7
|
-
setUrl(
|
|
7
|
+
setUrl(options: {
|
|
8
|
+
url: string;
|
|
9
|
+
}): Promise<any>;
|
|
8
10
|
}
|
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAuB;QAClC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { InAppBrowserPlugin, OpenWebViewOptions, OpenOptions } from './definitions';\n\nexport class InAppBrowserWeb extends WebPlugin implements InAppBrowserPlugin {\n async open(options: OpenOptions): Promise<any> {\n console.log('open', options);\n return options;\n }\n async openWebView(options: OpenWebViewOptions): Promise<any> {\n console.log('openWebView', options);\n return options;\n }\n async close(): Promise<any> {\n console.log('close');\n return;\n }\n async setUrl(options: { url: string}): Promise<any> {\n console.log('setUrl', options.url);\n return;\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst InAppBrowser = registerPlugin('InAppBrowser', {\n web: () => import('./web').then(m => new m.InAppBrowserWeb()),\n});\nexport * from './definitions';\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log('open', options);\n return options;\n }\n async openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n async setUrl(
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst InAppBrowser = registerPlugin('InAppBrowser', {\n web: () => import('./web').then(m => new m.InAppBrowserWeb()),\n});\nexport * from './definitions';\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log('open', options);\n return options;\n }\n async openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n async setUrl(options) {\n console.log('setUrl', options.url);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;;;;AAAWA,6BAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;AAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACLhC,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACjE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAC3C,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst InAppBrowser = registerPlugin('InAppBrowser', {\n web: () => import('./web').then(m => new m.InAppBrowserWeb()),\n});\nexport * from './definitions';\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log('open', options);\n return options;\n }\n async openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n async setUrl(
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst InAppBrowser = registerPlugin('InAppBrowser', {\n web: () => import('./web').then(m => new m.InAppBrowserWeb()),\n});\nexport * from './definitions';\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log('open', options);\n return options;\n }\n async openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n async setUrl(options) {\n console.log('setUrl', options.url);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,iCAAY;IACvB,CAAC,UAAU,WAAW,EAAE;IACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACLhC,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -12,6 +12,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
12
12
|
private var isSetupDone = false
|
|
13
13
|
var currentPluginCall: CAPPluginCall?
|
|
14
14
|
var isPresentAfterPageLoad = false
|
|
15
|
+
var webViewController: WKWebViewController?
|
|
15
16
|
|
|
16
17
|
private func setup(){
|
|
17
18
|
self.isSetupDone = true
|
|
@@ -59,25 +60,24 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
59
60
|
|
|
60
61
|
DispatchQueue.main.async {
|
|
61
62
|
let url = URL(string: urlString)
|
|
62
|
-
let webViewController: WKWebViewController?
|
|
63
63
|
|
|
64
64
|
if self.isPresentAfterPageLoad {
|
|
65
|
-
webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
65
|
+
self.webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
66
66
|
} else {
|
|
67
|
-
webViewController = WKWebViewController.init()
|
|
68
|
-
webViewController?.setHeaders(headers: headers)
|
|
67
|
+
self.webViewController = WKWebViewController.init()
|
|
68
|
+
self.webViewController?.setHeaders(headers: headers)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
webViewController?.source = .remote(url!)
|
|
72
|
-
webViewController?.leftNavigaionBarItemTypes = self.getToolbarItems(toolbarType: toolbarType ?? "")
|
|
71
|
+
self.webViewController?.source = .remote(url!)
|
|
72
|
+
self.webViewController?.leftNavigaionBarItemTypes = self.getToolbarItems(toolbarType: toolbarType ?? "")
|
|
73
73
|
|
|
74
|
-
webViewController?.toolbarItemTypes = []
|
|
75
|
-
webViewController?.doneBarButtonItemPosition = .right
|
|
76
|
-
webViewController?.capBrowserPlugin = self
|
|
77
|
-
webViewController?.title = call.getString("title") ?? ""
|
|
78
|
-
webViewController?.shareSubject = call.getString("shareSubject")
|
|
79
|
-
webViewController?.shareDisclaimer = disclaimerContent
|
|
80
|
-
self.navigationWebViewController = UINavigationController.init(rootViewController: webViewController!)
|
|
74
|
+
self.webViewController?.toolbarItemTypes = []
|
|
75
|
+
self.webViewController?.doneBarButtonItemPosition = .right
|
|
76
|
+
self.webViewController?.capBrowserPlugin = self
|
|
77
|
+
self.webViewController?.title = call.getString("title") ?? ""
|
|
78
|
+
self.webViewController?.shareSubject = call.getString("shareSubject")
|
|
79
|
+
self.webViewController?.shareDisclaimer = disclaimerContent
|
|
80
|
+
self.navigationWebViewController = UINavigationController.init(rootViewController: self.webViewController!)
|
|
81
81
|
self.navigationWebViewController?.navigationBar.isTranslucent = false
|
|
82
82
|
self.navigationWebViewController?.toolbar.isTranslucent = false
|
|
83
83
|
self.navigationWebViewController?.navigationBar.backgroundColor = .white
|
|
@@ -104,6 +104,11 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
@objc func setUrl(_ call: CAPPluginCall) {
|
|
107
|
+
guard let url = call.getString("url") else {
|
|
108
|
+
call.reject("Cannot get new url to set")
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
self.webViewController?.load(remote: URL(string: url)!)
|
|
107
112
|
call.resolve()
|
|
108
113
|
}
|
|
109
114
|
|
|
@@ -130,21 +135,20 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
130
135
|
|
|
131
136
|
DispatchQueue.main.async {
|
|
132
137
|
let url = URL(string: urlString)
|
|
133
|
-
let webViewController: WKWebViewController?
|
|
134
138
|
|
|
135
139
|
if self.isPresentAfterPageLoad {
|
|
136
|
-
webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
140
|
+
self.webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
137
141
|
} else {
|
|
138
|
-
webViewController = WKWebViewController.init()
|
|
139
|
-
webViewController?.setHeaders(headers: headers)
|
|
142
|
+
self.webViewController = WKWebViewController.init()
|
|
143
|
+
self.webViewController?.setHeaders(headers: headers)
|
|
140
144
|
}
|
|
141
145
|
|
|
142
|
-
webViewController?.source = .remote(url!)
|
|
143
|
-
webViewController?.leftNavigaionBarItemTypes = [.reload]
|
|
144
|
-
webViewController?.toolbarItemTypes = [.back, .forward, .activity]
|
|
145
|
-
webViewController?.capBrowserPlugin = self
|
|
146
|
-
webViewController?.hasDynamicTitle = true
|
|
147
|
-
self.navigationWebViewController = UINavigationController.init(rootViewController: webViewController!)
|
|
146
|
+
self.webViewController?.source = .remote(url!)
|
|
147
|
+
self.webViewController?.leftNavigaionBarItemTypes = [.reload]
|
|
148
|
+
self.webViewController?.toolbarItemTypes = [.back, .forward, .activity]
|
|
149
|
+
self.webViewController?.capBrowserPlugin = self
|
|
150
|
+
self.webViewController?.hasDynamicTitle = true
|
|
151
|
+
self.navigationWebViewController = UINavigationController.init(rootViewController: self.webViewController!)
|
|
148
152
|
self.navigationWebViewController?.navigationBar.isTranslucent = false
|
|
149
153
|
self.navigationWebViewController?.toolbar.isTranslucent = false
|
|
150
154
|
self.navigationWebViewController?.navigationBar.backgroundColor = .white
|