@capgo/inappbrowser 0.4.11 → 0.4.12
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 +1 -0
- package/android/src/main/AndroidManifest.xml +9 -1
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +26 -0
- package/dist/docs.json +7 -0
- package/dist/esm/definitions.d.ts +1 -0
- package/dist/esm/definitions.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -189,6 +189,7 @@ Remove all listeners for this plugin.
|
|
|
189
189
|
| **`url`** | <code>string</code> | Target URL to load. | 0.1.0 |
|
|
190
190
|
| **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | 0.1.0 |
|
|
191
191
|
| **`isPresentAfterPageLoad`** | <code>boolean</code> | if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | 0.1.0 |
|
|
192
|
+
| **`preventDeeplink`** | <code>boolean</code> | | |
|
|
192
193
|
|
|
193
194
|
|
|
194
195
|
#### Headers
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
1
2
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
3
|
package="ee.forgr.capacitor_inappbrowser">
|
|
3
|
-
|
|
4
|
+
<queries>
|
|
5
|
+
<intent>
|
|
6
|
+
<action android:name="android.intent.action.VIEW" />
|
|
7
|
+
<category android:name="android.intent.category.BROWSABLE" />
|
|
8
|
+
<data android:scheme="http" />
|
|
9
|
+
</intent>
|
|
10
|
+
</queries>
|
|
11
|
+
</manifest>
|
|
@@ -2,6 +2,8 @@ package ee.forgr.capacitor_inappbrowser;
|
|
|
2
2
|
|
|
3
3
|
import android.content.ComponentName;
|
|
4
4
|
import android.content.Intent;
|
|
5
|
+
import android.content.pm.PackageManager;
|
|
6
|
+
import android.content.pm.ResolveInfo;
|
|
5
7
|
import android.net.Uri;
|
|
6
8
|
import android.os.Bundle;
|
|
7
9
|
import android.text.TextUtils;
|
|
@@ -61,6 +63,10 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
61
63
|
@PluginMethod
|
|
62
64
|
public void open(PluginCall call) {
|
|
63
65
|
String url = call.getString("url");
|
|
66
|
+
|
|
67
|
+
// get the deeplink prevention, if provided
|
|
68
|
+
Boolean preventDeeplink = call.getBoolean("preventDeeplink", null);
|
|
69
|
+
|
|
64
70
|
if (url == null || TextUtils.isEmpty(url)) {
|
|
65
71
|
call.reject("Invalid URL");
|
|
66
72
|
}
|
|
@@ -78,6 +84,26 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
78
84
|
android.provider.Browser.EXTRA_HEADERS,
|
|
79
85
|
this.getHeaders(call)
|
|
80
86
|
);
|
|
87
|
+
|
|
88
|
+
if (preventDeeplink != null) {
|
|
89
|
+
String browserPackageName = "";
|
|
90
|
+
Intent browserIntent = new Intent(
|
|
91
|
+
Intent.ACTION_VIEW,
|
|
92
|
+
Uri.parse("http://")
|
|
93
|
+
);
|
|
94
|
+
ResolveInfo resolveInfo = getContext()
|
|
95
|
+
.getPackageManager()
|
|
96
|
+
.resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
|
97
|
+
|
|
98
|
+
if (resolveInfo != null) {
|
|
99
|
+
browserPackageName = resolveInfo.activityInfo.packageName;
|
|
100
|
+
|
|
101
|
+
if (!browserPackageName.isEmpty()) {
|
|
102
|
+
tabsIntent.intent.setPackage(browserPackageName);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
81
107
|
tabsIntent.launchUrl(getContext(), Uri.parse(url));
|
|
82
108
|
|
|
83
109
|
call.resolve();
|
package/dist/docs.json
CHANGED
|
@@ -227,6 +227,13 @@
|
|
|
227
227
|
"docs": "if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.",
|
|
228
228
|
"complexTypes": [],
|
|
229
229
|
"type": "boolean | undefined"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "preventDeeplink",
|
|
233
|
+
"tags": [],
|
|
234
|
+
"docs": "",
|
|
235
|
+
"complexTypes": [],
|
|
236
|
+
"type": "boolean | undefined"
|
|
230
237
|
}
|
|
231
238
|
]
|
|
232
239
|
},
|
|
@@ -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 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}\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 * 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\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 /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\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 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 /**\n * Listen for close click\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\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 /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\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 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 * 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\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 /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\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 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 /**\n * Listen for close click\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\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 /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n}\n"]}
|