@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.
Files changed (44) hide show
  1. package/CapgoNativeMarket.podspec +16 -12
  2. package/LICENSE +373 -21
  3. package/Package.swift +28 -0
  4. package/README.md +75 -49
  5. package/android/build.gradle +9 -9
  6. package/android/src/main/java/com/getcapacitor/community/nativemarket/NativeMarket.java +111 -112
  7. package/dist/docs.json +107 -35
  8. package/dist/esm/definitions.d.ts +82 -31
  9. package/dist/esm/index.d.ts +2 -2
  10. package/dist/esm/index.js +4 -4
  11. package/dist/esm/web.d.ts +10 -7
  12. package/dist/esm/web.js +14 -11
  13. package/dist/esm/web.js.map +1 -1
  14. package/dist/plugin.cjs.js +14 -11
  15. package/dist/plugin.cjs.js.map +1 -1
  16. package/dist/plugin.js +14 -11
  17. package/dist/plugin.js.map +1 -1
  18. package/ios/Sources/NativeMarketPlugin/NativeMarketPlugin.swift +120 -0
  19. package/ios/Tests/NativeMarketPluginTests/NativeMarketPluginTests.swift +20 -0
  20. package/package.json +59 -54
  21. package/android/.classpath +0 -6
  22. package/android/android.iml +0 -109
  23. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  24. package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  25. package/android/gradle.properties +0 -20
  26. package/android/gradlew +0 -244
  27. package/android/gradlew.bat +0 -92
  28. package/android/proguard-rules.pro +0 -21
  29. package/android/settings.gradle +0 -2
  30. package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +0 -28
  31. package/android/src/main/res/layout/bridge_layout_main.xml +0 -15
  32. package/android/src/main/res/values/colors.xml +0 -3
  33. package/android/src/main/res/values/strings.xml +0 -3
  34. package/android/src/main/res/values/styles.xml +0 -3
  35. package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +0 -18
  36. package/ios/Plugin/Info.plist +0 -24
  37. package/ios/Plugin/Plugin.h +0 -10
  38. package/ios/Plugin/Plugin.m +0 -12
  39. package/ios/Plugin/Plugin.swift +0 -94
  40. package/ios/Plugin.xcodeproj/project.pbxproj +0 -556
  41. package/ios/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  42. package/ios/PluginTests/Info.plist +0 -22
  43. package/ios/PluginTests/PluginTests.swift +0 -35
  44. 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
- * This method will launch link in Play/App Store.
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
- * This method will deep-link directly to an Play/App store listing page.
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
- * This method will link users to a collection or top charts.
32
- * Only in Android.
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
- * This method will link users to Editor's choice page.
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
- * This method will link users to custom search query.
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
  }
@@ -1,4 +1,4 @@
1
- import type { NativeMarketPlugin } from "./definitions";
1
+ import type { NativeMarketPlugin } from './definitions';
2
2
  declare const NativeMarket: NativeMarketPlugin;
3
- export * from "./definitions";
3
+ export * from './definitions';
4
4
  export { NativeMarket };
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { registerPlugin } from "@capacitor/core";
2
- const NativeMarket = registerPlugin("NativeMarket", {
3
- web: () => import("./web").then((m) => new m.NativeMarketWeb()),
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 "./definitions";
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 "@capacitor/core";
2
- import type { NativeMarketPlugin } from "./definitions";
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { NativeMarketPlugin } from './definitions';
3
3
  export declare class NativeMarketWeb extends WebPlugin implements NativeMarketPlugin {
4
- openStoreListing(_options: {
4
+ openStoreListing(options: {
5
5
  appId: string;
6
6
  country?: string;
7
7
  }): Promise<void>;
8
- openDevPage(_options: {
8
+ openDevPage(options: {
9
9
  devId: string;
10
10
  }): Promise<void>;
11
- openCollection(_options: {
11
+ openCollection(options: {
12
12
  name: string;
13
13
  }): Promise<void>;
14
- openEditorChoicePage(_options: {
14
+ openEditorChoicePage(options: {
15
15
  editorChoice: string;
16
16
  }): Promise<void>;
17
- search(_options: {
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 "@capacitor/core";
1
+ import { WebPlugin } from '@capacitor/core';
2
2
  export class NativeMarketWeb extends WebPlugin {
3
- openStoreListing(_options) {
4
- throw new Error("Method not implemented.");
3
+ openStoreListing(options) {
4
+ throw new Error('Method not implemented.' + options);
5
5
  }
6
- openDevPage(_options) {
7
- throw new Error("Method not implemented.");
6
+ openDevPage(options) {
7
+ throw new Error('Method not implemented.' + options);
8
8
  }
9
- openCollection(_options) {
10
- throw new Error("Method not implemented.");
9
+ openCollection(options) {
10
+ throw new Error('Method not implemented.' + options);
11
11
  }
12
- openEditorChoicePage(_options) {
13
- throw new Error("Method not implemented.");
12
+ openEditorChoicePage(options) {
13
+ throw new Error('Method not implemented.' + options);
14
14
  }
15
- search(_options) {
16
- throw new Error("Method not implemented.");
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
@@ -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,QAGhB;QACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,WAAW,CAAC,QAA2B;QACrC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,cAAc,CAAC,QAA0B;QACvC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,oBAAoB,CAAC,QAAkC;QACrD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,QAA2B;QAChC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF"}
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"}
@@ -2,25 +2,28 @@
2
2
 
3
3
  var core = require('@capacitor/core');
4
4
 
5
- const NativeMarket = core.registerPlugin("NativeMarket", {
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(_options) {
11
- throw new Error("Method not implemented.");
10
+ openStoreListing(options) {
11
+ throw new Error('Method not implemented.' + options);
12
12
  }
13
- openDevPage(_options) {
14
- throw new Error("Method not implemented.");
13
+ openDevPage(options) {
14
+ throw new Error('Method not implemented.' + options);
15
15
  }
16
- openCollection(_options) {
17
- throw new Error("Method not implemented.");
16
+ openCollection(options) {
17
+ throw new Error('Method not implemented.' + options);
18
18
  }
19
- openEditorChoicePage(_options) {
20
- throw new Error("Method not implemented.");
19
+ openEditorChoicePage(options) {
20
+ throw new Error('Method not implemented.' + options);
21
21
  }
22
- search(_options) {
23
- throw new Error("Method not implemented.");
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
 
@@ -1 +1 @@
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.\");\n }\n openDevPage(_options) {\n throw new Error(\"Method not implemented.\");\n }\n openCollection(_options) {\n throw new Error(\"Method not implemented.\");\n }\n openEditorChoicePage(_options) {\n throw new Error(\"Method not implemented.\");\n }\n search(_options) {\n throw new Error(\"Method not implemented.\");\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,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,WAAW,CAAC,QAAQ,EAAE;AAC1B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,cAAc,CAAC,QAAQ,EAAE;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,oBAAoB,CAAC,QAAQ,EAAE;AACnC,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,MAAM,CAAC,QAAQ,EAAE;AACrB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;;;;;;;;;"}
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("NativeMarket", {
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(_options) {
10
- throw new Error("Method not implemented.");
9
+ openStoreListing(options) {
10
+ throw new Error('Method not implemented.' + options);
11
11
  }
12
- openDevPage(_options) {
13
- throw new Error("Method not implemented.");
12
+ openDevPage(options) {
13
+ throw new Error('Method not implemented.' + options);
14
14
  }
15
- openCollection(_options) {
16
- throw new Error("Method not implemented.");
15
+ openCollection(options) {
16
+ throw new Error('Method not implemented.' + options);
17
17
  }
18
- openEditorChoicePage(_options) {
19
- throw new Error("Method not implemented.");
18
+ openEditorChoicePage(options) {
19
+ throw new Error('Method not implemented.' + options);
20
20
  }
21
- search(_options) {
22
- throw new Error("Method not implemented.");
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
 
@@ -1 +1 @@
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.\");\n }\n openDevPage(_options) {\n throw new Error(\"Method not implemented.\");\n }\n openCollection(_options) {\n throw new Error(\"Method not implemented.\");\n }\n openEditorChoicePage(_options) {\n throw new Error(\"Method not implemented.\");\n }\n search(_options) {\n throw new Error(\"Method not implemented.\");\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,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL,IAAI,WAAW,CAAC,QAAQ,EAAE;IAC1B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL,IAAI,cAAc,CAAC,QAAQ,EAAE;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL,IAAI,oBAAoB,CAAC,QAAQ,EAAE;IACnC,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL,IAAI,MAAM,CAAC,QAAQ,EAAE;IACrB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;;;;;;;;;;;;;;;"}
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.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/esm/index.js",
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": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
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 -- --autocorrect --format",
15
- "eslint": "eslint . --ext ts",
16
- "prettier": "prettier --config .prettierrc.js \"**/*.{css,html,ts,js,java}\"",
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": "^5.0.3",
31
- "@capacitor/cli": "^5.0.3",
32
- "@capacitor/core": "^5.0.3",
33
- "@capacitor/docgen": "^0.2.1",
34
- "@capacitor/ios": "^5.0.3",
35
- "@ionic/eslint-config": "^0.3.0",
36
- "@ionic/prettier-config": "^3.0.0",
37
- "@ionic/swiftlint-config": "^1.1.2",
38
- "@typescript-eslint/eslint-plugin": "^5.59.7",
39
- "@typescript-eslint/parser": "^5.59.7",
40
- "eslint": "^8.41.0",
41
- "eslint-plugin-import": "^2.27.5",
42
- "husky": "^8.0.3",
43
- "prettier": "^2.8.8",
44
- "prettier-plugin-java": "^2.1.0",
45
- "rimraf": "^5.0.1",
46
- "rollup": "^3.23.0",
47
- "swiftlint": "^1.0.2",
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
- "files": [
51
- "dist/",
52
- "ios/",
53
- "android/",
54
- "CapgoNativeMarket.podspec"
55
- ],
56
- "keywords": [
57
- "capacitor",
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
  }
@@ -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>