capacitor-launch-native 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/CapacitorLaunchNative.podspec +17 -0
- package/README.md +37 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/dev/harding/plugins/launchnative/LaunchNative.java +81 -0
- package/android/src/main/java/dev/harding/plugins/launchnative/LaunchNativePlugin.java +23 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +31 -0
- package/dist/esm/definitions.d.ts +7 -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 +7 -0
- package/dist/esm/web.js +7 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +23 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +26 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/LaunchNativePlugin.h +10 -0
- package/ios/Plugin/LaunchNativePlugin.m +8 -0
- package/ios/Plugin/LaunchNativePlugin.swift +29 -0
- package/package.json +77 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CapacitorLaunchNative'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# capacitor-launch-native
|
|
2
|
+
|
|
3
|
+
Launch an app natively, if it exists
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install capacitor-launch-native
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
<docgen-index>
|
|
15
|
+
|
|
16
|
+
* [`attempt(...)`](#attempt)
|
|
17
|
+
|
|
18
|
+
</docgen-index>
|
|
19
|
+
|
|
20
|
+
<docgen-api>
|
|
21
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
22
|
+
|
|
23
|
+
### attempt(...)
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
attempt(options: { url: string; }) => Promise<{ completed: boolean; }>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| Param | Type |
|
|
30
|
+
| ------------- | ----------------------------- |
|
|
31
|
+
| **`options`** | <code>{ url: string; }</code> |
|
|
32
|
+
|
|
33
|
+
**Returns:** <code>Promise<{ completed: boolean; }></code>
|
|
34
|
+
|
|
35
|
+
--------------------
|
|
36
|
+
|
|
37
|
+
</docgen-api>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.0.0'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "dev.harding.plugins.launchnative"
|
|
22
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package dev.harding.plugins.launchnative;
|
|
2
|
+
|
|
3
|
+
import android.content.ActivityNotFoundException;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.content.Intent;
|
|
6
|
+
import android.content.pm.PackageManager;
|
|
7
|
+
import android.content.pm.ResolveInfo;
|
|
8
|
+
import android.net.Uri;
|
|
9
|
+
import android.os.Build;
|
|
10
|
+
import java.util.HashSet;
|
|
11
|
+
import java.util.List;
|
|
12
|
+
import java.util.Set;
|
|
13
|
+
|
|
14
|
+
// https://developer.chrome.com/blog/custom-tabs-android-11
|
|
15
|
+
public class LaunchNative {
|
|
16
|
+
public boolean attempt(Context context, String url) {
|
|
17
|
+
Uri uri = Uri.parse(url);
|
|
18
|
+
|
|
19
|
+
return Build.VERSION.SDK_INT >= 30 ?
|
|
20
|
+
launchNativeApi30(context, uri) :
|
|
21
|
+
launchNativeBeforeApi30(context, uri);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static boolean launchNativeApi30(Context context, Uri uri) {
|
|
25
|
+
Intent nativeAppIntent = new Intent(Intent.ACTION_VIEW, uri)
|
|
26
|
+
.addCategory(Intent.CATEGORY_BROWSABLE)
|
|
27
|
+
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
|
|
28
|
+
Intent.FLAG_ACTIVITY_REQUIRE_NON_BROWSER);
|
|
29
|
+
try {
|
|
30
|
+
context.startActivity(nativeAppIntent);
|
|
31
|
+
return true;
|
|
32
|
+
} catch (ActivityNotFoundException ex) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private static boolean launchNativeBeforeApi30(Context context, Uri uri) {
|
|
38
|
+
PackageManager pm = context.getPackageManager();
|
|
39
|
+
|
|
40
|
+
// Get all Apps that resolve a generic url
|
|
41
|
+
Intent browserActivityIntent = new Intent()
|
|
42
|
+
.setAction(Intent.ACTION_VIEW)
|
|
43
|
+
.addCategory(Intent.CATEGORY_BROWSABLE)
|
|
44
|
+
.setData(Uri.fromParts("http", "", null));
|
|
45
|
+
Set<String> genericResolvedList = extractPackageNames(
|
|
46
|
+
pm.queryIntentActivities(browserActivityIntent, 0));
|
|
47
|
+
|
|
48
|
+
// Get all apps that resolve the specific Url
|
|
49
|
+
Intent specializedActivityIntent = new Intent(Intent.ACTION_VIEW, uri)
|
|
50
|
+
.addCategory(Intent.CATEGORY_BROWSABLE);
|
|
51
|
+
Set<String> resolvedSpecializedList = extractPackageNames(
|
|
52
|
+
pm.queryIntentActivities(specializedActivityIntent, 0));
|
|
53
|
+
|
|
54
|
+
// Keep only the Urls that resolve the specific, but not the generic
|
|
55
|
+
// urls.
|
|
56
|
+
resolvedSpecializedList.removeAll(genericResolvedList);
|
|
57
|
+
|
|
58
|
+
// If the list is empty, no native app handlers were found.
|
|
59
|
+
if (resolvedSpecializedList.isEmpty()) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// We found native handlers. Launch the Intent.
|
|
64
|
+
specializedActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
65
|
+
context.startActivity(specializedActivityIntent);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private static Set<String> extractPackageNames(List<ResolveInfo> resolveInfoList) {
|
|
70
|
+
Set<String> packageNames = new HashSet<>();
|
|
71
|
+
if (resolveInfoList != null) {
|
|
72
|
+
for (ResolveInfo resolveInfo : resolveInfoList) {
|
|
73
|
+
if (resolveInfo.activityInfo != null) {
|
|
74
|
+
packageNames.add(resolveInfo.activityInfo.packageName);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return packageNames;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package dev.harding.plugins.launchnative;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Plugin;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import com.getcapacitor.PluginMethod;
|
|
7
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
|
|
9
|
+
@CapacitorPlugin(name = "LaunchNative")
|
|
10
|
+
public class LaunchNativePlugin extends Plugin {
|
|
11
|
+
|
|
12
|
+
private LaunchNative implementation = new LaunchNative();
|
|
13
|
+
|
|
14
|
+
@PluginMethod
|
|
15
|
+
public void attempt(PluginCall call) {
|
|
16
|
+
String url = call.getString("url");
|
|
17
|
+
|
|
18
|
+
JSObject ret = new JSObject();
|
|
19
|
+
ret.put("completed", implementation.attempt(getContext(), url));
|
|
20
|
+
call.resolve(ret);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "LaunchNativePlugin",
|
|
4
|
+
"slug": "launchnativeplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "attempt",
|
|
10
|
+
"signature": "(options: { url: string; }) => Promise<{ completed: boolean; }>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "{ url: string; }"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<{ completed: boolean; }>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "",
|
|
21
|
+
"complexTypes": [],
|
|
22
|
+
"slug": "attempt"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"properties": []
|
|
26
|
+
},
|
|
27
|
+
"interfaces": [],
|
|
28
|
+
"enums": [],
|
|
29
|
+
"typeAliases": [],
|
|
30
|
+
"pluginConfigs": []
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface LaunchNativePlugin {\n attempt(options: { url: string }): Promise<{ completed: boolean }>;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const LaunchNative = registerPlugin('LaunchNative', {
|
|
3
|
+
web: () => import('./web').then(m => new m.LaunchNativeWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { LaunchNative };
|
|
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,YAAY,GAAG,cAAc,CAAqB,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { LaunchNativePlugin } from './definitions';\n\nconst LaunchNative = registerPlugin<LaunchNativePlugin>('LaunchNative', {\n web: () => import('./web').then(m => new m.LaunchNativeWeb()),\n});\n\nexport * from './definitions';\nexport { LaunchNative };\n"]}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +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,OAAO;QACX,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { LaunchNativePlugin } from './definitions';\n\nexport class LaunchNativeWeb extends WebPlugin implements LaunchNativePlugin {\n async attempt(): Promise<{ completed: boolean }> {\n return { completed: false };\n }\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
|
|
7
|
+
const LaunchNative = core.registerPlugin('LaunchNative', {
|
|
8
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.LaunchNativeWeb()),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
class LaunchNativeWeb extends core.WebPlugin {
|
|
12
|
+
async attempt() {
|
|
13
|
+
return { completed: false };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
18
|
+
__proto__: null,
|
|
19
|
+
LaunchNativeWeb: LaunchNativeWeb
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
exports.LaunchNative = LaunchNative;
|
|
23
|
+
//# 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 LaunchNative = registerPlugin('LaunchNative', {\n web: () => import('./web').then(m => new m.LaunchNativeWeb()),\n});\nexport * from './definitions';\nexport { LaunchNative };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class LaunchNativeWeb extends WebPlugin {\n async attempt() {\n return { completed: false };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,YAAY,GAAGA,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,OAAO,GAAG;AACpB,QAAQ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACpC,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var capacitorLaunchNative = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const LaunchNative = core.registerPlugin('LaunchNative', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.LaunchNativeWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class LaunchNativeWeb extends core.WebPlugin {
|
|
9
|
+
async attempt() {
|
|
10
|
+
return { completed: false };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
15
|
+
__proto__: null,
|
|
16
|
+
LaunchNativeWeb: LaunchNativeWeb
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
exports.LaunchNative = LaunchNative;
|
|
20
|
+
|
|
21
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
22
|
+
|
|
23
|
+
return exports;
|
|
24
|
+
|
|
25
|
+
})({}, capacitorExports);
|
|
26
|
+
//# 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 LaunchNative = registerPlugin('LaunchNative', {\n web: () => import('./web').then(m => new m.LaunchNativeWeb()),\n});\nexport * from './definitions';\nexport { LaunchNative };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class LaunchNativeWeb extends WebPlugin {\n async attempt() {\n return { completed: false };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,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,OAAO,GAAG;IACpB,QAAQ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACpC,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -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>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
//! Project version number for Plugin.
|
|
4
|
+
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
+
|
|
6
|
+
//! Project version string for Plugin.
|
|
7
|
+
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
+
|
|
9
|
+
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <Capacitor/Capacitor.h>
|
|
3
|
+
|
|
4
|
+
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
+
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
+
CAP_PLUGIN(LaunchNativePlugin, "LaunchNative",
|
|
7
|
+
CAP_PLUGIN_METHOD(attempt, CAPPluginReturnPromise);
|
|
8
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
*/
|
|
8
|
+
@objc(LaunchNativePlugin)
|
|
9
|
+
public class LaunchNativePlugin: CAPPlugin {
|
|
10
|
+
@objc func attempt(_ call: CAPPluginCall) {
|
|
11
|
+
let url = call.getString("url") ?? ""
|
|
12
|
+
|
|
13
|
+
let parsedUrl = URL(string: url)!
|
|
14
|
+
|
|
15
|
+
DispatchQueue.main.async {
|
|
16
|
+
UIApplication.shared.open(parsedUrl, options: [.universalLinksOnly: true]) { success in
|
|
17
|
+
if success {
|
|
18
|
+
call.resolve([
|
|
19
|
+
"completed": true
|
|
20
|
+
])
|
|
21
|
+
} else {
|
|
22
|
+
call.resolve([
|
|
23
|
+
"completed": false
|
|
24
|
+
])
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "capacitor-launch-native",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Launch an app natively, if it exists",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Plugin/",
|
|
14
|
+
"CapacitorLaunchNative.podspec"
|
|
15
|
+
],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/aeharding/capacitor-launch-native.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/aeharding/capacitor-launch-native/issues"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"capacitor",
|
|
27
|
+
"plugin",
|
|
28
|
+
"native"
|
|
29
|
+
],
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@capacitor/android": "^5.0.0",
|
|
32
|
+
"@capacitor/core": "^5.0.0",
|
|
33
|
+
"@capacitor/docgen": "^0.0.18",
|
|
34
|
+
"@capacitor/ios": "^5.0.0",
|
|
35
|
+
"@ionic/eslint-config": "^0.3.0",
|
|
36
|
+
"@ionic/prettier-config": "^1.0.1",
|
|
37
|
+
"@ionic/swiftlint-config": "^1.1.2",
|
|
38
|
+
"eslint": "^7.11.0",
|
|
39
|
+
"prettier": "~2.3.0",
|
|
40
|
+
"prettier-plugin-java": "~1.0.2",
|
|
41
|
+
"rimraf": "^3.0.2",
|
|
42
|
+
"rollup": "^2.32.0",
|
|
43
|
+
"swiftlint": "^1.0.1",
|
|
44
|
+
"typescript": "~4.1.5"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@capacitor/core": "^5.0.0"
|
|
48
|
+
},
|
|
49
|
+
"prettier": "@ionic/prettier-config",
|
|
50
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
51
|
+
"eslintConfig": {
|
|
52
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
53
|
+
},
|
|
54
|
+
"capacitor": {
|
|
55
|
+
"ios": {
|
|
56
|
+
"src": "ios"
|
|
57
|
+
},
|
|
58
|
+
"android": {
|
|
59
|
+
"src": "android"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
64
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
|
|
65
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
66
|
+
"verify:web": "npm run build",
|
|
67
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
68
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
69
|
+
"eslint": "eslint . --ext ts",
|
|
70
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
71
|
+
"swiftlint": "node-swiftlint",
|
|
72
|
+
"docgen": "docgen --api LaunchNativePlugin --output-readme README.md --output-json dist/docs.json",
|
|
73
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
|
|
74
|
+
"clean": "rimraf ./dist",
|
|
75
|
+
"watch": "tsc --watch"
|
|
76
|
+
}
|
|
77
|
+
}
|