@capawesome/capacitor-app-launcher 0.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.
- package/CapawesomeCapacitorAppLauncher.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +218 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/AppLauncher.java +79 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/AppLauncherPlugin.java +98 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/classes/CustomExceptions.java +6 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/classes/options/CanOpenUrlOptions.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/classes/options/OpenUrlOptions.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/classes/results/CanOpenUrlResult.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/classes/results/OpenUrlResult.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/applauncher/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +184 -0
- package/dist/esm/definitions.d.ts +83 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +6 -0
- package/dist/esm/web.js +11 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +25 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +28 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/AppLauncher.swift +32 -0
- package/ios/Plugin/AppLauncherPlugin.swift +63 -0
- package/ios/Plugin/Classes/Options/CanOpenUrlOptions.swift +13 -0
- package/ios/Plugin/Classes/Options/OpenUrlOptions.swift +13 -0
- package/ios/Plugin/Classes/Results/CanOpenUrlResult.swift +16 -0
- package/ios/Plugin/Classes/Results/OpenUrlResult.swift +16 -0
- package/ios/Plugin/Enums/CustomError.swift +21 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +5 -0
- package/package.json +93 -0
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "AppLauncherPlugin",
|
|
4
|
+
"slug": "applauncherplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "canOpenUrl",
|
|
10
|
+
"signature": "(options: CanOpenUrlOptions) => Promise<CanOpenUrlResult>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "CanOpenUrlOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<CanOpenUrlResult>",
|
|
19
|
+
"tags": [
|
|
20
|
+
{
|
|
21
|
+
"name": "since",
|
|
22
|
+
"text": "0.1.0"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"docs": "Check if an app can be opened with the given URL.\n\nOn **iOS**, every URL scheme you want to check must be declared in the\n`LSApplicationQueriesSchemes` key of your app's `Info.plist`. Otherwise\nthis method always resolves with `value: false`.\n\nOn **Android**, every package name or URL scheme you want to check must be\ndeclared in the `<queries>` element of your app's `AndroidManifest.xml`.\nOtherwise this method always resolves with `value: false`.",
|
|
26
|
+
"complexTypes": [
|
|
27
|
+
"CanOpenUrlResult",
|
|
28
|
+
"CanOpenUrlOptions"
|
|
29
|
+
],
|
|
30
|
+
"slug": "canopenurl"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "openUrl",
|
|
34
|
+
"signature": "(options: OpenUrlOptions) => Promise<OpenUrlResult>",
|
|
35
|
+
"parameters": [
|
|
36
|
+
{
|
|
37
|
+
"name": "options",
|
|
38
|
+
"docs": "",
|
|
39
|
+
"type": "OpenUrlOptions"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"returns": "Promise<OpenUrlResult>",
|
|
43
|
+
"tags": [
|
|
44
|
+
{
|
|
45
|
+
"name": "since",
|
|
46
|
+
"text": "0.1.0"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"docs": "Open an app with the given URL.",
|
|
50
|
+
"complexTypes": [
|
|
51
|
+
"OpenUrlResult",
|
|
52
|
+
"OpenUrlOptions"
|
|
53
|
+
],
|
|
54
|
+
"slug": "openurl"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"properties": []
|
|
58
|
+
},
|
|
59
|
+
"interfaces": [
|
|
60
|
+
{
|
|
61
|
+
"name": "CanOpenUrlResult",
|
|
62
|
+
"slug": "canopenurlresult",
|
|
63
|
+
"docs": "",
|
|
64
|
+
"tags": [
|
|
65
|
+
{
|
|
66
|
+
"text": "0.1.0",
|
|
67
|
+
"name": "since"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"methods": [],
|
|
71
|
+
"properties": [
|
|
72
|
+
{
|
|
73
|
+
"name": "value",
|
|
74
|
+
"tags": [
|
|
75
|
+
{
|
|
76
|
+
"text": "0.1.0",
|
|
77
|
+
"name": "since"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"text": "true",
|
|
81
|
+
"name": "example"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"docs": "Whether or not the app can be opened with the given URL.\n\nOn the web, this is always `true` because the browser cannot determine\nwhether a URL can be opened.",
|
|
85
|
+
"complexTypes": [],
|
|
86
|
+
"type": "boolean"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "CanOpenUrlOptions",
|
|
92
|
+
"slug": "canopenurloptions",
|
|
93
|
+
"docs": "",
|
|
94
|
+
"tags": [
|
|
95
|
+
{
|
|
96
|
+
"text": "0.1.0",
|
|
97
|
+
"name": "since"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"methods": [],
|
|
101
|
+
"properties": [
|
|
102
|
+
{
|
|
103
|
+
"name": "url",
|
|
104
|
+
"tags": [
|
|
105
|
+
{
|
|
106
|
+
"text": "0.1.0",
|
|
107
|
+
"name": "since"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"text": "'mailto:'",
|
|
111
|
+
"name": "example"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"docs": "The URL to check.\n\nOn **iOS**, this must be a URL scheme (e.g. `mailto:`).\n\nOn **Android**, this can be a URL scheme (e.g. `mailto:`) or a package name\n(e.g. `com.google.android.gm`).",
|
|
115
|
+
"complexTypes": [],
|
|
116
|
+
"type": "string"
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "OpenUrlResult",
|
|
122
|
+
"slug": "openurlresult",
|
|
123
|
+
"docs": "",
|
|
124
|
+
"tags": [
|
|
125
|
+
{
|
|
126
|
+
"text": "0.1.0",
|
|
127
|
+
"name": "since"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"methods": [],
|
|
131
|
+
"properties": [
|
|
132
|
+
{
|
|
133
|
+
"name": "completed",
|
|
134
|
+
"tags": [
|
|
135
|
+
{
|
|
136
|
+
"text": "0.1.0",
|
|
137
|
+
"name": "since"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"text": "true",
|
|
141
|
+
"name": "example"
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"docs": "Whether or not the app was opened successfully.",
|
|
145
|
+
"complexTypes": [],
|
|
146
|
+
"type": "boolean"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "OpenUrlOptions",
|
|
152
|
+
"slug": "openurloptions",
|
|
153
|
+
"docs": "",
|
|
154
|
+
"tags": [
|
|
155
|
+
{
|
|
156
|
+
"text": "0.1.0",
|
|
157
|
+
"name": "since"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"methods": [],
|
|
161
|
+
"properties": [
|
|
162
|
+
{
|
|
163
|
+
"name": "url",
|
|
164
|
+
"tags": [
|
|
165
|
+
{
|
|
166
|
+
"text": "0.1.0",
|
|
167
|
+
"name": "since"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"text": "'mailto:'",
|
|
171
|
+
"name": "example"
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"docs": "The URL to open.\n\nOn **iOS**, this must be a URL scheme (e.g. `mailto:`).\n\nOn **Android**, this can be a URL scheme (e.g. `mailto:`) or a package name\n(e.g. `com.google.android.gm`).",
|
|
175
|
+
"complexTypes": [],
|
|
176
|
+
"type": "string"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"enums": [],
|
|
182
|
+
"typeAliases": [],
|
|
183
|
+
"pluginConfigs": []
|
|
184
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface AppLauncherPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Check if an app can be opened with the given URL.
|
|
4
|
+
*
|
|
5
|
+
* On **iOS**, every URL scheme you want to check must be declared in the
|
|
6
|
+
* `LSApplicationQueriesSchemes` key of your app's `Info.plist`. Otherwise
|
|
7
|
+
* this method always resolves with `value: false`.
|
|
8
|
+
*
|
|
9
|
+
* On **Android**, every package name or URL scheme you want to check must be
|
|
10
|
+
* declared in the `<queries>` element of your app's `AndroidManifest.xml`.
|
|
11
|
+
* Otherwise this method always resolves with `value: false`.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
canOpenUrl(options: CanOpenUrlOptions): Promise<CanOpenUrlResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Open an app with the given URL.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*/
|
|
21
|
+
openUrl(options: OpenUrlOptions): Promise<OpenUrlResult>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @since 0.1.0
|
|
25
|
+
*/
|
|
26
|
+
export interface CanOpenUrlOptions {
|
|
27
|
+
/**
|
|
28
|
+
* The URL to check.
|
|
29
|
+
*
|
|
30
|
+
* On **iOS**, this must be a URL scheme (e.g. `mailto:`).
|
|
31
|
+
*
|
|
32
|
+
* On **Android**, this can be a URL scheme (e.g. `mailto:`) or a package name
|
|
33
|
+
* (e.g. `com.google.android.gm`).
|
|
34
|
+
*
|
|
35
|
+
* @since 0.1.0
|
|
36
|
+
* @example 'mailto:'
|
|
37
|
+
*/
|
|
38
|
+
url: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @since 0.1.0
|
|
42
|
+
*/
|
|
43
|
+
export interface CanOpenUrlResult {
|
|
44
|
+
/**
|
|
45
|
+
* Whether or not the app can be opened with the given URL.
|
|
46
|
+
*
|
|
47
|
+
* On the web, this is always `true` because the browser cannot determine
|
|
48
|
+
* whether a URL can be opened.
|
|
49
|
+
*
|
|
50
|
+
* @since 0.1.0
|
|
51
|
+
* @example true
|
|
52
|
+
*/
|
|
53
|
+
value: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @since 0.1.0
|
|
57
|
+
*/
|
|
58
|
+
export interface OpenUrlOptions {
|
|
59
|
+
/**
|
|
60
|
+
* The URL to open.
|
|
61
|
+
*
|
|
62
|
+
* On **iOS**, this must be a URL scheme (e.g. `mailto:`).
|
|
63
|
+
*
|
|
64
|
+
* On **Android**, this can be a URL scheme (e.g. `mailto:`) or a package name
|
|
65
|
+
* (e.g. `com.google.android.gm`).
|
|
66
|
+
*
|
|
67
|
+
* @since 0.1.0
|
|
68
|
+
* @example 'mailto:'
|
|
69
|
+
*/
|
|
70
|
+
url: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @since 0.1.0
|
|
74
|
+
*/
|
|
75
|
+
export interface OpenUrlResult {
|
|
76
|
+
/**
|
|
77
|
+
* Whether or not the app was opened successfully.
|
|
78
|
+
*
|
|
79
|
+
* @since 0.1.0
|
|
80
|
+
* @example true
|
|
81
|
+
*/
|
|
82
|
+
completed: boolean;
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface AppLauncherPlugin {\n /**\n * Check if an app can be opened with the given URL.\n *\n * On **iOS**, every URL scheme you want to check must be declared in the\n * `LSApplicationQueriesSchemes` key of your app's `Info.plist`. Otherwise\n * this method always resolves with `value: false`.\n *\n * On **Android**, every package name or URL scheme you want to check must be\n * declared in the `<queries>` element of your app's `AndroidManifest.xml`.\n * Otherwise this method always resolves with `value: false`.\n *\n * @since 0.1.0\n */\n canOpenUrl(options: CanOpenUrlOptions): Promise<CanOpenUrlResult>;\n /**\n * Open an app with the given URL.\n *\n * @since 0.1.0\n */\n openUrl(options: OpenUrlOptions): Promise<OpenUrlResult>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface CanOpenUrlOptions {\n /**\n * The URL to check.\n *\n * On **iOS**, this must be a URL scheme (e.g. `mailto:`).\n *\n * On **Android**, this can be a URL scheme (e.g. `mailto:`) or a package name\n * (e.g. `com.google.android.gm`).\n *\n * @since 0.1.0\n * @example 'mailto:'\n */\n url: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface CanOpenUrlResult {\n /**\n * Whether or not the app can be opened with the given URL.\n *\n * On the web, this is always `true` because the browser cannot determine\n * whether a URL can be opened.\n *\n * @since 0.1.0\n * @example true\n */\n value: boolean;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface OpenUrlOptions {\n /**\n * The URL to open.\n *\n * On **iOS**, this must be a URL scheme (e.g. `mailto:`).\n *\n * On **Android**, this can be a URL scheme (e.g. `mailto:`) or a package name\n * (e.g. `com.google.android.gm`).\n *\n * @since 0.1.0\n * @example 'mailto:'\n */\n url: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface OpenUrlResult {\n /**\n * Whether or not the app was opened successfully.\n *\n * @since 0.1.0\n * @example true\n */\n completed: boolean;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const AppLauncher = registerPlugin('AppLauncher', {
|
|
3
|
+
web: () => import('./web').then(m => new m.AppLauncherWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { AppLauncher };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,WAAW,GAAG,cAAc,CAAoB,aAAa,EAAE;IACnE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC7D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { AppLauncherPlugin } from './definitions';\n\nconst AppLauncher = registerPlugin<AppLauncherPlugin>('AppLauncher', {\n web: () => import('./web').then(m => new m.AppLauncherWeb()),\n});\n\nexport * from './definitions';\nexport { AppLauncher };\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { AppLauncherPlugin, CanOpenUrlOptions, CanOpenUrlResult, OpenUrlOptions, OpenUrlResult } from './definitions';
|
|
3
|
+
export declare class AppLauncherWeb extends WebPlugin implements AppLauncherPlugin {
|
|
4
|
+
canOpenUrl(_options: CanOpenUrlOptions): Promise<CanOpenUrlResult>;
|
|
5
|
+
openUrl(options: OpenUrlOptions): Promise<OpenUrlResult>;
|
|
6
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class AppLauncherWeb extends WebPlugin {
|
|
3
|
+
async canOpenUrl(_options) {
|
|
4
|
+
return { value: true };
|
|
5
|
+
}
|
|
6
|
+
async openUrl(options) {
|
|
7
|
+
const target = window.open(options.url, '_blank');
|
|
8
|
+
return { completed: target !== null };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C,KAAK,CAAC,UAAU,CAAC,QAA2B;QAC1C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAuB;QACnC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAClD,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC;IACxC,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AppLauncherPlugin,\n CanOpenUrlOptions,\n CanOpenUrlResult,\n OpenUrlOptions,\n OpenUrlResult,\n} from './definitions';\n\nexport class AppLauncherWeb extends WebPlugin implements AppLauncherPlugin {\n async canOpenUrl(_options: CanOpenUrlOptions): Promise<CanOpenUrlResult> {\n return { value: true };\n }\n\n async openUrl(options: OpenUrlOptions): Promise<OpenUrlResult> {\n const target = window.open(options.url, '_blank');\n return { completed: target !== null };\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
const AppLauncher = core.registerPlugin('AppLauncher', {
|
|
6
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AppLauncherWeb()),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
class AppLauncherWeb extends core.WebPlugin {
|
|
10
|
+
async canOpenUrl(_options) {
|
|
11
|
+
return { value: true };
|
|
12
|
+
}
|
|
13
|
+
async openUrl(options) {
|
|
14
|
+
const target = window.open(options.url, '_blank');
|
|
15
|
+
return { completed: target !== null };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
20
|
+
__proto__: null,
|
|
21
|
+
AppLauncherWeb: AppLauncherWeb
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
exports.AppLauncher = AppLauncher;
|
|
25
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst AppLauncher = registerPlugin('AppLauncher', {\n web: () => import('./web').then(m => new m.AppLauncherWeb()),\n});\nexport * from './definitions';\nexport { AppLauncher };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class AppLauncherWeb extends WebPlugin {\n async canOpenUrl(_options) {\n return { value: true };\n }\n async openUrl(options) {\n const target = window.open(options.url, '_blank');\n return { completed: target !== null };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,WAAW,GAAGA,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAChE,CAAC;;ACFM,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;AAC9B,IAAI;AACJ,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE;AAC3B,QAAQ,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC;AACzD,QAAQ,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,EAAE;AAC7C,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var capacitorAppLauncher = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const AppLauncher = core.registerPlugin('AppLauncher', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AppLauncherWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class AppLauncherWeb extends core.WebPlugin {
|
|
9
|
+
async canOpenUrl(_options) {
|
|
10
|
+
return { value: true };
|
|
11
|
+
}
|
|
12
|
+
async openUrl(options) {
|
|
13
|
+
const target = window.open(options.url, '_blank');
|
|
14
|
+
return { completed: target !== null };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
19
|
+
__proto__: null,
|
|
20
|
+
AppLauncherWeb: AppLauncherWeb
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
exports.AppLauncher = AppLauncher;
|
|
24
|
+
|
|
25
|
+
return exports;
|
|
26
|
+
|
|
27
|
+
})({}, capacitorExports);
|
|
28
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst AppLauncher = registerPlugin('AppLauncher', {\n web: () => import('./web').then(m => new m.AppLauncherWeb()),\n});\nexport * from './definitions';\nexport { AppLauncher };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class AppLauncherWeb extends WebPlugin {\n async canOpenUrl(_options) {\n return { value: true };\n }\n async openUrl(options) {\n const target = window.open(options.url, '_blank');\n return { completed: target !== null };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,WAAW,GAAGA,mBAAc,CAAC,aAAa,EAAE;IAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;IAChE,CAAC;;ICFM,MAAM,cAAc,SAASC,cAAS,CAAC;IAC9C,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;IAC9B,IAAI;IACJ,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE;IAC3B,QAAQ,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC;IACzD,QAAQ,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,EAAE;IAC7C,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
@objc public class AppLauncher: NSObject {
|
|
6
|
+
private let plugin: AppLauncherPlugin
|
|
7
|
+
|
|
8
|
+
init(plugin: AppLauncherPlugin) {
|
|
9
|
+
self.plugin = plugin
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@objc public func canOpenUrl(_ options: CanOpenUrlOptions, completion: @escaping (CanOpenUrlResult?, Error?) -> Void) {
|
|
13
|
+
guard let url = URL(string: options.url) else {
|
|
14
|
+
completion(CanOpenUrlResult(value: false), nil)
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
let value = UIApplication.shared.canOpenURL(url)
|
|
18
|
+
completion(CanOpenUrlResult(value: value), nil)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@objc public func openUrl(_ options: OpenUrlOptions, completion: @escaping (OpenUrlResult?, Error?) -> Void) {
|
|
22
|
+
guard let url = URL(string: options.url) else {
|
|
23
|
+
completion(OpenUrlResult(completed: false), nil)
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
DispatchQueue.main.async {
|
|
27
|
+
UIApplication.shared.open(url, options: [:]) { success in
|
|
28
|
+
completion(OpenUrlResult(completed: success), nil)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc(AppLauncherPlugin)
|
|
5
|
+
public class AppLauncherPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
6
|
+
public let identifier = "AppLauncherPlugin"
|
|
7
|
+
public let jsName = "AppLauncher"
|
|
8
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
9
|
+
CAPPluginMethod(name: "canOpenUrl", returnType: CAPPluginReturnPromise),
|
|
10
|
+
CAPPluginMethod(name: "openUrl", returnType: CAPPluginReturnPromise)
|
|
11
|
+
]
|
|
12
|
+
public static let tag = "AppLauncherPlugin"
|
|
13
|
+
|
|
14
|
+
private var implementation: AppLauncher?
|
|
15
|
+
|
|
16
|
+
override public func load() {
|
|
17
|
+
self.implementation = AppLauncher(plugin: self)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@objc func canOpenUrl(_ call: CAPPluginCall) {
|
|
21
|
+
do {
|
|
22
|
+
let options = try CanOpenUrlOptions(call)
|
|
23
|
+
implementation?.canOpenUrl(options) { result, error in
|
|
24
|
+
if let error = error {
|
|
25
|
+
self.rejectCall(call, error)
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
self.resolveCall(call, result)
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
self.rejectCall(call, error)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@objc func openUrl(_ call: CAPPluginCall) {
|
|
36
|
+
do {
|
|
37
|
+
let options = try OpenUrlOptions(call)
|
|
38
|
+
implementation?.openUrl(options) { result, error in
|
|
39
|
+
if let error = error {
|
|
40
|
+
self.rejectCall(call, error)
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
self.resolveCall(call, result)
|
|
44
|
+
}
|
|
45
|
+
} catch {
|
|
46
|
+
self.rejectCall(call, error)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private func rejectCall(_ call: CAPPluginCall, _ error: Error) {
|
|
51
|
+
CAPLog.print("[", AppLauncherPlugin.tag, "] ", error)
|
|
52
|
+
let code = (error as? CustomError)?.code
|
|
53
|
+
call.reject(error.localizedDescription, code)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private func resolveCall(_ call: CAPPluginCall, _ result: Result?) {
|
|
57
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
58
|
+
call.resolve(result)
|
|
59
|
+
} else {
|
|
60
|
+
call.resolve()
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class CanOpenUrlOptions: NSObject {
|
|
5
|
+
let url: String
|
|
6
|
+
|
|
7
|
+
init(_ call: CAPPluginCall) throws {
|
|
8
|
+
guard let url = call.getString("url") else {
|
|
9
|
+
throw CustomError.urlMissing
|
|
10
|
+
}
|
|
11
|
+
self.url = url
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class OpenUrlOptions: NSObject {
|
|
5
|
+
let url: String
|
|
6
|
+
|
|
7
|
+
init(_ call: CAPPluginCall) throws {
|
|
8
|
+
guard let url = call.getString("url") else {
|
|
9
|
+
throw CustomError.urlMissing
|
|
10
|
+
}
|
|
11
|
+
self.url = url
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class CanOpenUrlResult: NSObject, Result {
|
|
5
|
+
let value: Bool
|
|
6
|
+
|
|
7
|
+
init(value: Bool) {
|
|
8
|
+
self.value = value
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public func toJSObject() -> AnyObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
result["value"] = value
|
|
14
|
+
return result as AnyObject
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class OpenUrlResult: NSObject, Result {
|
|
5
|
+
let completed: Bool
|
|
6
|
+
|
|
7
|
+
init(completed: Bool) {
|
|
8
|
+
self.completed = completed
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public func toJSObject() -> AnyObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
result["completed"] = completed
|
|
14
|
+
return result as AnyObject
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
enum CustomError: Error {
|
|
4
|
+
case urlMissing
|
|
5
|
+
|
|
6
|
+
var code: String? {
|
|
7
|
+
switch self {
|
|
8
|
+
case .urlMissing:
|
|
9
|
+
return nil
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
extension CustomError: LocalizedError {
|
|
15
|
+
public var errorDescription: String? {
|
|
16
|
+
switch self {
|
|
17
|
+
case .urlMissing:
|
|
18
|
+
return NSLocalizedString("url must be provided.", comment: "urlMissing")
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|