@capgo/native-market 8.0.0 → 8.0.2
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/CapgoNativeMarket.podspec +16 -12
- package/LICENSE +373 -21
- package/Package.swift +28 -0
- package/README.md +75 -49
- package/android/build.gradle +9 -9
- package/android/src/main/java/com/getcapacitor/community/nativemarket/NativeMarket.java +111 -112
- package/dist/docs.json +107 -35
- package/dist/esm/definitions.d.ts +82 -31
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/web.d.ts +10 -7
- package/dist/esm/web.js +14 -11
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +14 -11
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +14 -11
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/NativeMarketPlugin/NativeMarketPlugin.swift +120 -0
- package/ios/Tests/NativeMarketPluginTests/NativeMarketPluginTests.swift +20 -0
- package/package.json +59 -54
- package/android/.classpath +0 -6
- package/android/android.iml +0 -109
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/android/gradle.properties +0 -20
- package/android/gradlew +0 -244
- package/android/gradlew.bat +0 -92
- package/android/proguard-rules.pro +0 -21
- package/android/settings.gradle +0 -2
- package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +0 -28
- package/android/src/main/res/layout/bridge_layout_main.xml +0 -15
- package/android/src/main/res/values/colors.xml +0 -3
- package/android/src/main/res/values/strings.xml +0 -3
- package/android/src/main/res/values/styles.xml +0 -3
- package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +0 -18
- package/ios/Plugin/Info.plist +0 -24
- package/ios/Plugin/Plugin.h +0 -10
- package/ios/Plugin/Plugin.m +0 -12
- package/ios/Plugin/Plugin.swift +0 -94
- package/ios/Plugin.xcodeproj/project.pbxproj +0 -556
- package/ios/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/PluginTests/Info.plist +0 -22
- package/ios/PluginTests/PluginTests.swift +0 -35
- package/ios/Podfile +0 -16
|
@@ -1,69 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capacitor Native Market Plugin for opening app store listings and pages.
|
|
3
|
+
*
|
|
4
|
+
* @since 1.0.0
|
|
5
|
+
*/
|
|
1
6
|
export interface NativeMarketPlugin {
|
|
2
7
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param {String} appId - ID of your application. Eg. com.example.app
|
|
6
|
-
* @param {String} [country] - International country code if application is not published in the US App store (only for iOS). Eg. IT
|
|
7
|
-
*
|
|
8
|
-
* @returns void
|
|
8
|
+
* Launch app listing page in Play Store (Android) or App Store (iOS).
|
|
9
9
|
*
|
|
10
|
+
* @param options - Configuration for opening the store listing
|
|
11
|
+
* @returns Promise that resolves when the store is opened
|
|
12
|
+
* @throws Error if opening the store fails
|
|
10
13
|
* @since 1.0.0
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Open app in store
|
|
17
|
+
* await NativeMarket.openStoreListing({
|
|
18
|
+
* appId: 'com.example.app'
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Open app in specific country store (iOS only)
|
|
22
|
+
* await NativeMarket.openStoreListing({
|
|
23
|
+
* appId: 'com.example.app',
|
|
24
|
+
* country: 'IT'
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
11
27
|
*/
|
|
12
28
|
openStoreListing(options: {
|
|
13
29
|
appId: string;
|
|
14
30
|
country?: string;
|
|
15
31
|
}): Promise<void>;
|
|
16
32
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Only in Android.
|
|
20
|
-
*
|
|
21
|
-
* @param {String} devId - ID of developer. Eg. com.example.app
|
|
22
|
-
*
|
|
23
|
-
* @returns void
|
|
33
|
+
* Deep-link directly to a developer's page in the Play Store.
|
|
34
|
+
* Android only.
|
|
24
35
|
*
|
|
36
|
+
* @param options - Configuration with developer ID
|
|
37
|
+
* @returns Promise that resolves when the page is opened
|
|
38
|
+
* @throws Error if opening the page fails or if called on iOS
|
|
25
39
|
* @since 1.0.0
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* await NativeMarket.openDevPage({
|
|
43
|
+
* devId: 'Google+LLC'
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
26
46
|
*/
|
|
27
47
|
openDevPage(options: {
|
|
28
48
|
devId: string;
|
|
29
49
|
}): Promise<void>;
|
|
30
50
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @param {String} name - name of the collection. Click [here](https://developer.android.com/distribute/marketing-tools/linking-to-google-play#OpeningCollection) for android options.
|
|
35
|
-
*
|
|
36
|
-
* @returns void
|
|
51
|
+
* Link users to a collection or top charts in the Play Store.
|
|
52
|
+
* Android only.
|
|
37
53
|
*
|
|
54
|
+
* @param options - Configuration with collection name
|
|
55
|
+
* @returns Promise that resolves when the collection is opened
|
|
56
|
+
* @throws Error if opening the collection fails or if called on iOS
|
|
38
57
|
* @since 1.0.0
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* await NativeMarket.openCollection({
|
|
61
|
+
* name: 'featured'
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
* @see https://developer.android.com/distribute/marketing-tools/linking-to-google-play#OpeningCollection
|
|
39
65
|
*/
|
|
40
66
|
openCollection(options: {
|
|
41
67
|
name: string;
|
|
42
68
|
}): Promise<void>;
|
|
43
69
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* Only in Android.
|
|
47
|
-
*
|
|
48
|
-
* @param {String} editorChoice - ID of your application. Eg. editorial_fitness_apps_us
|
|
49
|
-
* @returns void
|
|
70
|
+
* Link users to Editor's choice page in the Play Store.
|
|
71
|
+
* Android only.
|
|
50
72
|
*
|
|
73
|
+
* @param options - Configuration with editor choice ID
|
|
74
|
+
* @returns Promise that resolves when the page is opened
|
|
75
|
+
* @throws Error if opening the page fails or if called on iOS
|
|
51
76
|
* @since 1.0.0
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* await NativeMarket.openEditorChoicePage({
|
|
80
|
+
* editorChoice: 'editorial_fitness_apps_us'
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
52
83
|
*/
|
|
53
84
|
openEditorChoicePage(options: {
|
|
54
85
|
editorChoice: string;
|
|
55
86
|
}): Promise<void>;
|
|
56
87
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* Only in Android.
|
|
60
|
-
*
|
|
61
|
-
* @param {String} editorChoice - terms to be searched in Play/App store.
|
|
62
|
-
* @returns void
|
|
88
|
+
* Search the Play Store with custom search terms.
|
|
89
|
+
* Android only.
|
|
63
90
|
*
|
|
91
|
+
* @param options - Configuration with search terms
|
|
92
|
+
* @returns Promise that resolves when the search is opened
|
|
93
|
+
* @throws Error if opening search fails or if called on iOS
|
|
64
94
|
* @since 1.0.0
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* await NativeMarket.search({
|
|
98
|
+
* terms: 'fitness apps'
|
|
99
|
+
* });
|
|
100
|
+
* ```
|
|
65
101
|
*/
|
|
66
102
|
search(options: {
|
|
67
103
|
terms: string;
|
|
68
104
|
}): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Get the native Capacitor plugin version.
|
|
107
|
+
*
|
|
108
|
+
* @returns Promise that resolves with the plugin version
|
|
109
|
+
* @throws Error if getting the version fails
|
|
110
|
+
* @since 1.0.0
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const { version } = await NativeMarket.getPluginVersion();
|
|
114
|
+
* console.log('Plugin version:', version);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
getPluginVersion(): Promise<{
|
|
118
|
+
version: string;
|
|
119
|
+
}>;
|
|
69
120
|
}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { registerPlugin } from
|
|
2
|
-
const NativeMarket = registerPlugin(
|
|
3
|
-
web: () => import(
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const NativeMarket = registerPlugin('NativeMarket', {
|
|
3
|
+
web: () => import('./web').then((m) => new m.NativeMarketWeb()),
|
|
4
4
|
});
|
|
5
|
-
export * from
|
|
5
|
+
export * from './definitions';
|
|
6
6
|
export { NativeMarket };
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import { WebPlugin } from
|
|
2
|
-
import type { NativeMarketPlugin } from
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { NativeMarketPlugin } from './definitions';
|
|
3
3
|
export declare class NativeMarketWeb extends WebPlugin implements NativeMarketPlugin {
|
|
4
|
-
openStoreListing(
|
|
4
|
+
openStoreListing(options: {
|
|
5
5
|
appId: string;
|
|
6
6
|
country?: string;
|
|
7
7
|
}): Promise<void>;
|
|
8
|
-
openDevPage(
|
|
8
|
+
openDevPage(options: {
|
|
9
9
|
devId: string;
|
|
10
10
|
}): Promise<void>;
|
|
11
|
-
openCollection(
|
|
11
|
+
openCollection(options: {
|
|
12
12
|
name: string;
|
|
13
13
|
}): Promise<void>;
|
|
14
|
-
openEditorChoicePage(
|
|
14
|
+
openEditorChoicePage(options: {
|
|
15
15
|
editorChoice: string;
|
|
16
16
|
}): Promise<void>;
|
|
17
|
-
search(
|
|
17
|
+
search(options: {
|
|
18
18
|
terms: string;
|
|
19
19
|
}): Promise<void>;
|
|
20
|
+
getPluginVersion(): Promise<{
|
|
21
|
+
version: string;
|
|
22
|
+
}>;
|
|
20
23
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { WebPlugin } from
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
2
|
export class NativeMarketWeb extends WebPlugin {
|
|
3
|
-
openStoreListing(
|
|
4
|
-
throw new Error(
|
|
3
|
+
openStoreListing(options) {
|
|
4
|
+
throw new Error('Method not implemented.' + options);
|
|
5
5
|
}
|
|
6
|
-
openDevPage(
|
|
7
|
-
throw new Error(
|
|
6
|
+
openDevPage(options) {
|
|
7
|
+
throw new Error('Method not implemented.' + options);
|
|
8
8
|
}
|
|
9
|
-
openCollection(
|
|
10
|
-
throw new Error(
|
|
9
|
+
openCollection(options) {
|
|
10
|
+
throw new Error('Method not implemented.' + options);
|
|
11
11
|
}
|
|
12
|
-
openEditorChoicePage(
|
|
13
|
-
throw new Error(
|
|
12
|
+
openEditorChoicePage(options) {
|
|
13
|
+
throw new Error('Method not implemented.' + options);
|
|
14
14
|
}
|
|
15
|
-
search(
|
|
16
|
-
throw new Error(
|
|
15
|
+
search(options) {
|
|
16
|
+
throw new Error('Method not implemented.' + options);
|
|
17
|
+
}
|
|
18
|
+
async getPluginVersion() {
|
|
19
|
+
return { version: 'web' };
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
//# sourceMappingURL=web.js.map
|
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,gBAAgB,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,gBAAgB,CAAC,OAA4C;QAC3D,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,WAAW,CAAC,OAA0B;QACpC,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,cAAc,CAAC,OAAyB;QACtC,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,oBAAoB,CAAC,OAAiC;QACpD,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,OAA0B;QAC/B,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -2,25 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@capacitor/core');
|
|
4
4
|
|
|
5
|
-
const NativeMarket = core.registerPlugin(
|
|
5
|
+
const NativeMarket = core.registerPlugin('NativeMarket', {
|
|
6
6
|
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.NativeMarketWeb()),
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
class NativeMarketWeb extends core.WebPlugin {
|
|
10
|
-
openStoreListing(
|
|
11
|
-
throw new Error(
|
|
10
|
+
openStoreListing(options) {
|
|
11
|
+
throw new Error('Method not implemented.' + options);
|
|
12
12
|
}
|
|
13
|
-
openDevPage(
|
|
14
|
-
throw new Error(
|
|
13
|
+
openDevPage(options) {
|
|
14
|
+
throw new Error('Method not implemented.' + options);
|
|
15
15
|
}
|
|
16
|
-
openCollection(
|
|
17
|
-
throw new Error(
|
|
16
|
+
openCollection(options) {
|
|
17
|
+
throw new Error('Method not implemented.' + options);
|
|
18
18
|
}
|
|
19
|
-
openEditorChoicePage(
|
|
20
|
-
throw new Error(
|
|
19
|
+
openEditorChoicePage(options) {
|
|
20
|
+
throw new Error('Method not implemented.' + options);
|
|
21
21
|
}
|
|
22
|
-
search(
|
|
23
|
-
throw new Error(
|
|
22
|
+
search(options) {
|
|
23
|
+
throw new Error('Method not implemented.' + options);
|
|
24
|
+
}
|
|
25
|
+
async getPluginVersion() {
|
|
26
|
+
return { version: 'web' };
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst NativeMarket = registerPlugin('NativeMarket', {\n web: () => import('./web').then((m) => new m.NativeMarketWeb()),\n});\nexport * from './definitions';\nexport { NativeMarket };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class NativeMarketWeb extends WebPlugin {\n openStoreListing(options) {\n throw new Error('Method not implemented.' + options);\n }\n openDevPage(options) {\n throw new Error('Method not implemented.' + options);\n }\n openCollection(options) {\n throw new Error('Method not implemented.' + options);\n }\n openEditorChoicePage(options) {\n throw new Error('Method not implemented.' + options);\n }\n search(options) {\n throw new Error('Method not implemented.' + options);\n }\n async getPluginVersion() {\n return { version: 'web' };\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,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,gBAAgB,CAAC,OAAO,EAAE;AAC9B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;AAC5D,IAAI;AACJ,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;AAC5D,IAAI;AACJ,IAAI,cAAc,CAAC,OAAO,EAAE;AAC5B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;AAC5D,IAAI;AACJ,IAAI,oBAAoB,CAAC,OAAO,EAAE;AAClC,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;AAC5D,IAAI;AACJ,IAAI,MAAM,CAAC,OAAO,EAAE;AACpB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;AAC5D,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
var capacitorCapacitorUpdater = (function (exports, core) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const NativeMarket = core.registerPlugin(
|
|
4
|
+
const NativeMarket = core.registerPlugin('NativeMarket', {
|
|
5
5
|
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.NativeMarketWeb()),
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
class NativeMarketWeb extends core.WebPlugin {
|
|
9
|
-
openStoreListing(
|
|
10
|
-
throw new Error(
|
|
9
|
+
openStoreListing(options) {
|
|
10
|
+
throw new Error('Method not implemented.' + options);
|
|
11
11
|
}
|
|
12
|
-
openDevPage(
|
|
13
|
-
throw new Error(
|
|
12
|
+
openDevPage(options) {
|
|
13
|
+
throw new Error('Method not implemented.' + options);
|
|
14
14
|
}
|
|
15
|
-
openCollection(
|
|
16
|
-
throw new Error(
|
|
15
|
+
openCollection(options) {
|
|
16
|
+
throw new Error('Method not implemented.' + options);
|
|
17
17
|
}
|
|
18
|
-
openEditorChoicePage(
|
|
19
|
-
throw new Error(
|
|
18
|
+
openEditorChoicePage(options) {
|
|
19
|
+
throw new Error('Method not implemented.' + options);
|
|
20
20
|
}
|
|
21
|
-
search(
|
|
22
|
-
throw new Error(
|
|
21
|
+
search(options) {
|
|
22
|
+
throw new Error('Method not implemented.' + options);
|
|
23
|
+
}
|
|
24
|
+
async getPluginVersion() {
|
|
25
|
+
return { version: 'web' };
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst NativeMarket = registerPlugin('NativeMarket', {\n web: () => import('./web').then((m) => new m.NativeMarketWeb()),\n});\nexport * from './definitions';\nexport { NativeMarket };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class NativeMarketWeb extends WebPlugin {\n openStoreListing(options) {\n throw new Error('Method not implemented.' + options);\n }\n openDevPage(options) {\n throw new Error('Method not implemented.' + options);\n }\n openCollection(options) {\n throw new Error('Method not implemented.' + options);\n }\n openEditorChoicePage(options) {\n throw new Error('Method not implemented.' + options);\n }\n search(options) {\n throw new Error('Method not implemented.' + options);\n }\n async getPluginVersion() {\n return { version: 'web' };\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,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,gBAAgB,CAAC,OAAO,EAAE;IAC9B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;IAC5D,IAAI;IACJ,IAAI,WAAW,CAAC,OAAO,EAAE;IACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;IAC5D,IAAI;IACJ,IAAI,cAAc,CAAC,OAAO,EAAE;IAC5B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;IAC5D,IAAI;IACJ,IAAI,oBAAoB,CAAC,OAAO,EAAE;IAClC,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;IAC5D,IAAI;IACJ,IAAI,MAAM,CAAC,OAAO,EAAE;IACpB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,OAAO,CAAC;IAC5D,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
struct APIResult: Codable {
|
|
5
|
+
struct App: Codable {
|
|
6
|
+
let trackId: Int
|
|
7
|
+
|
|
8
|
+
enum CodingKeys: String, CodingKey {
|
|
9
|
+
case trackId
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let resultCount: Int
|
|
14
|
+
let apps: [App]
|
|
15
|
+
|
|
16
|
+
enum CodingKeys: String, CodingKey {
|
|
17
|
+
case resultCount
|
|
18
|
+
case apps = "results"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
24
|
+
* here: https://capacitor.ionicframework.com/docs/plugins/ios
|
|
25
|
+
*/
|
|
26
|
+
@objc(NativeMarket)
|
|
27
|
+
public class NativeMarket: CAPPlugin, CAPBridgedPlugin {
|
|
28
|
+
private let pluginVersion: String = "8.0.2"
|
|
29
|
+
public let identifier = "NativeMarketPlugin"
|
|
30
|
+
public let jsName = "NativeMarket"
|
|
31
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
32
|
+
CAPPluginMethod(name: "openStoreListing", returnType: CAPPluginReturnPromise),
|
|
33
|
+
CAPPluginMethod(name: "openDevPage", returnType: CAPPluginReturnPromise),
|
|
34
|
+
CAPPluginMethod(name: "openCollection", returnType: CAPPluginReturnPromise),
|
|
35
|
+
CAPPluginMethod(name: "openEditorChoicePage", returnType: CAPPluginReturnPromise),
|
|
36
|
+
CAPPluginMethod(name: "search", returnType: CAPPluginReturnPromise),
|
|
37
|
+
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
|
|
38
|
+
]
|
|
39
|
+
@objc func openStoreListing(_ call: CAPPluginCall) {
|
|
40
|
+
guard let appId = call.getString("appId") else {
|
|
41
|
+
call.reject("appId is missing")
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
let country = call.getString("country") ?? ""
|
|
45
|
+
do {
|
|
46
|
+
guard let url = URL(string: "https://itunes.apple.com/lookup?bundleId=\(appId)&country=\(country)") else {
|
|
47
|
+
throw NSError(domain: "Invalid URL", code: 0, userInfo: nil)
|
|
48
|
+
}
|
|
49
|
+
let data = try Data(contentsOf: url)
|
|
50
|
+
let decoder = JSONDecoder()
|
|
51
|
+
let apiResult = try decoder.decode(APIResult.self, from: data)
|
|
52
|
+
|
|
53
|
+
guard let firstApp = apiResult.apps.first else {
|
|
54
|
+
print("No apps found for given appId")
|
|
55
|
+
call.reject("No apps found for given appId")
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let urlStore = "itms-apps://itunes.apple.com/app/id\(firstApp.trackId)"
|
|
60
|
+
guard let appUrl = URL(string: urlStore) else {
|
|
61
|
+
throw NSError(domain: "Invalid Store URL", code: 0, userInfo: nil)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
DispatchQueue.main.async {
|
|
65
|
+
if UIApplication.shared.canOpenURL(appUrl) {
|
|
66
|
+
if #available(iOS 10.0, *) {
|
|
67
|
+
UIApplication.shared.open(appUrl, options: [:]) { (_) in
|
|
68
|
+
call.resolve()
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
UIApplication.shared.openURL(appUrl)
|
|
72
|
+
call.resolve()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
print("Error: \(error.localizedDescription)")
|
|
78
|
+
call.reject("Error: \(error.localizedDescription)")
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@objc func openDevPage(_ call: CAPPluginCall) {
|
|
83
|
+
call.unimplemented("openDevPage is not implemented on iOS.")
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@objc func openCollection(_ call: CAPPluginCall) {
|
|
87
|
+
call.unimplemented("openCollection is not implemented on iOS.")
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@objc func openEditorChoicePage(_ call: CAPPluginCall) {
|
|
91
|
+
call.unimplemented("openEditorChoicePage is not implemented on iOS.")
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@objc func search(_ call: CAPPluginCall) {
|
|
95
|
+
if call.hasOption("terms") {
|
|
96
|
+
let terms = call.getString("terms")
|
|
97
|
+
|
|
98
|
+
let url = "itms-apps://itunes.apple.com/search?term=" + terms!
|
|
99
|
+
let appUrl = URL(string: url)
|
|
100
|
+
|
|
101
|
+
if UIApplication.shared.canOpenURL(appUrl!) {
|
|
102
|
+
if #available(iOS 10.0, *) {
|
|
103
|
+
UIApplication.shared.open(appUrl!, options: [:]) { (_) in
|
|
104
|
+
call.resolve()
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
UIApplication.shared.openURL(appUrl!)
|
|
108
|
+
call.resolve()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
call.reject("terms is missing")
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@objc func getPluginVersion(_ call: CAPPluginCall) {
|
|
117
|
+
call.resolve(["version": self.pluginVersion])
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import XCTest
|
|
2
|
+
@testable import NativeMarketPlugin
|
|
3
|
+
|
|
4
|
+
final class NativeMarketPluginTests: XCTestCase {
|
|
5
|
+
func testApiResultDecoding() throws {
|
|
6
|
+
let payload = """
|
|
7
|
+
{
|
|
8
|
+
"resultCount": 1,
|
|
9
|
+
"results": [
|
|
10
|
+
{ "trackId": 42 }
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
""".data(using: .utf8)!
|
|
14
|
+
|
|
15
|
+
let decoded = try JSONDecoder().decode(APIResult.self, from: payload)
|
|
16
|
+
|
|
17
|
+
XCTAssertEqual(decoded.resultCount, 1)
|
|
18
|
+
XCTAssertEqual(decoded.apps.first?.trackId, 42)
|
|
19
|
+
}
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,63 +1,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/native-market",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"description": "A native market plugin for linking to google play or app store.",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
|
-
"main": "dist/
|
|
6
|
+
"main": "dist/plugin.cjs.js",
|
|
7
7
|
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"author": "Martin Donadieu <martin@capgo.app>",
|
|
9
|
+
"license": "MPL-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Cap-go/capacitor-native-market.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/Cap-go/capacitor-native-market/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://capgo.app/docs/plugins/native-market/",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"capacitor",
|
|
20
|
+
"plugin",
|
|
21
|
+
"market",
|
|
22
|
+
"google play",
|
|
23
|
+
"app store"
|
|
24
|
+
],
|
|
25
|
+
"files": [
|
|
26
|
+
"android/src/main/",
|
|
27
|
+
"android/build.gradle",
|
|
28
|
+
"dist/",
|
|
29
|
+
"ios/Sources",
|
|
30
|
+
"ios/Tests",
|
|
31
|
+
"Package.swift",
|
|
32
|
+
"CapgoNativeMarket.podspec"
|
|
33
|
+
],
|
|
8
34
|
"scripts": {
|
|
9
35
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
10
|
-
"verify:ios": "
|
|
36
|
+
"verify:ios": "xcodebuild -scheme CapgoNativeMarket -destination generic/platform=iOS",
|
|
11
37
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
12
38
|
"verify:web": "npm run build",
|
|
13
39
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
14
|
-
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --
|
|
15
|
-
"eslint": "eslint .
|
|
16
|
-
"prettier": "prettier
|
|
40
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
41
|
+
"eslint": "eslint .",
|
|
42
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
17
43
|
"swiftlint": "node-swiftlint",
|
|
44
|
+
"docgen": "docgen --api NativeMarketPlugin --output-readme README.md --output-json dist/docs.json",
|
|
18
45
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
19
46
|
"clean": "rimraf ./dist",
|
|
20
47
|
"watch": "tsc --watch",
|
|
21
|
-
"docgen": "docgen --api NativeMarketPlugin --output-readme README.md --output-json dist/docs.json",
|
|
22
48
|
"prepublishOnly": "npm run build"
|
|
23
49
|
},
|
|
24
|
-
"author": "Martin Donadieu <martindonadieu@gmail.com>",
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"@capacitor/core": "^5.0.3"
|
|
28
|
-
},
|
|
29
50
|
"devDependencies": {
|
|
30
|
-
"@capacitor/android": "^
|
|
31
|
-
"@capacitor/
|
|
32
|
-
"@capacitor/
|
|
33
|
-
"@capacitor/docgen": "^0.
|
|
34
|
-
"@capacitor/ios": "^
|
|
35
|
-
"@ionic/eslint-config": "^0.
|
|
36
|
-
"@ionic/prettier-config": "^
|
|
37
|
-
"@ionic/swiftlint-config": "^
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"eslint": "^
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"prettier": "^2.
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"typescript": "^5.0.4"
|
|
51
|
+
"@capacitor/android": "^8.0.0",
|
|
52
|
+
"@capacitor/core": "^8.0.0",
|
|
53
|
+
"@capacitor/cli": "^8.0.0",
|
|
54
|
+
"@capacitor/docgen": "^0.3.1",
|
|
55
|
+
"@capacitor/ios": "^8.0.0",
|
|
56
|
+
"@ionic/eslint-config": "^0.4.0",
|
|
57
|
+
"@ionic/prettier-config": "^4.0.0",
|
|
58
|
+
"@ionic/swiftlint-config": "^2.0.0",
|
|
59
|
+
"@types/node": "^24.10.1",
|
|
60
|
+
"eslint": "^8.57.1",
|
|
61
|
+
"eslint-plugin-import": "^2.31.0",
|
|
62
|
+
"husky": "^9.1.7",
|
|
63
|
+
"prettier": "^3.6.2",
|
|
64
|
+
"prettier-plugin-java": "^2.7.7",
|
|
65
|
+
"rimraf": "^6.1.0",
|
|
66
|
+
"rollup": "^4.53.2",
|
|
67
|
+
"swiftlint": "^2.0.0",
|
|
68
|
+
"typescript": "^5.9.3"
|
|
49
69
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
"plugin",
|
|
59
|
-
"native"
|
|
60
|
-
],
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"@capacitor/core": ">=8.0.0"
|
|
72
|
+
},
|
|
73
|
+
"eslintConfig": {
|
|
74
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
75
|
+
},
|
|
76
|
+
"prettier": "@ionic/prettier-config",
|
|
77
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
61
78
|
"capacitor": {
|
|
62
79
|
"ios": {
|
|
63
80
|
"src": "ios"
|
|
@@ -65,17 +82,5 @@
|
|
|
65
82
|
"android": {
|
|
66
83
|
"src": "android"
|
|
67
84
|
}
|
|
68
|
-
},
|
|
69
|
-
"prettier": "@ionic/prettier-config",
|
|
70
|
-
"swiftlint": "@ionic/swiftlint-config",
|
|
71
|
-
"eslintConfig": {
|
|
72
|
-
"extends": "@ionic/eslint-config/recommended"
|
|
73
|
-
},
|
|
74
|
-
"repository": {
|
|
75
|
-
"type": "git",
|
|
76
|
-
"url": "https://github.com/riderx/native-market"
|
|
77
|
-
},
|
|
78
|
-
"bugs": {
|
|
79
|
-
"url": "https://github.com/riderx/native-market/issues"
|
|
80
85
|
}
|
|
81
86
|
}
|
package/android/.classpath
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<classpath>
|
|
3
|
-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
|
|
4
|
-
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
|
5
|
-
<classpathentry kind="output" path="bin/default"/>
|
|
6
|
-
</classpath>
|