@capgo/capacitor-native-market 8.0.29

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/dist/plugin.js ADDED
@@ -0,0 +1,39 @@
1
+ var capacitorCapacitorUpdater = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const NativeMarket = core.registerPlugin('NativeMarket', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.NativeMarketWeb()),
6
+ });
7
+
8
+ class NativeMarketWeb extends core.WebPlugin {
9
+ openStoreListing(options) {
10
+ throw new Error('Method not implemented.' + options);
11
+ }
12
+ openDevPage(options) {
13
+ throw new Error('Method not implemented.' + options);
14
+ }
15
+ openCollection(options) {
16
+ throw new Error('Method not implemented.' + options);
17
+ }
18
+ openEditorChoicePage(options) {
19
+ throw new Error('Method not implemented.' + options);
20
+ }
21
+ search(options) {
22
+ throw new Error('Method not implemented.' + options);
23
+ }
24
+ async getPluginVersion() {
25
+ return { version: 'web' };
26
+ }
27
+ }
28
+
29
+ var web = /*#__PURE__*/Object.freeze({
30
+ __proto__: null,
31
+ NativeMarketWeb: NativeMarketWeb
32
+ });
33
+
34
+ exports.NativeMarket = NativeMarket;
35
+
36
+ return exports;
37
+
38
+ })({}, capacitorExports);
39
+ //# 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 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,110 @@
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.29"
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
+ UIApplication.shared.open(appUrl, options: [:]) { (_) in
67
+ call.resolve()
68
+ }
69
+ }
70
+ }
71
+ } catch {
72
+ print("Error: \(error.localizedDescription)")
73
+ call.reject("Error: \(error.localizedDescription)")
74
+ }
75
+ }
76
+
77
+ @objc func openDevPage(_ call: CAPPluginCall) {
78
+ call.unimplemented("openDevPage is not implemented on iOS.")
79
+ }
80
+
81
+ @objc func openCollection(_ call: CAPPluginCall) {
82
+ call.unimplemented("openCollection is not implemented on iOS.")
83
+ }
84
+
85
+ @objc func openEditorChoicePage(_ call: CAPPluginCall) {
86
+ call.unimplemented("openEditorChoicePage is not implemented on iOS.")
87
+ }
88
+
89
+ @objc func search(_ call: CAPPluginCall) {
90
+ if call.hasOption("terms") {
91
+ let terms = call.getString("terms")
92
+
93
+ let url = "itms-apps://itunes.apple.com/search?term=" + terms!
94
+ let appUrl = URL(string: url)
95
+
96
+ if UIApplication.shared.canOpenURL(appUrl!) {
97
+ UIApplication.shared.open(appUrl!, options: [:]) { (_) in
98
+ call.resolve()
99
+ }
100
+ }
101
+ } else {
102
+ call.reject("terms is missing")
103
+ }
104
+ }
105
+
106
+ @objc func getPluginVersion(_ call: CAPPluginCall) {
107
+ call.resolve(["version": self.pluginVersion])
108
+ }
109
+
110
+ }
@@ -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 ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@capgo/capacitor-native-market",
3
+ "version": "8.0.29",
4
+ "description": "A native market plugin for linking to google play or app store.",
5
+ "module": "dist/esm/index.js",
6
+ "main": "dist/plugin.cjs.js",
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
+ "CapgoCapacitorNativeMarket.podspec"
33
+ ],
34
+ "scripts": {
35
+ "verify": "bun run verify:ios && bun run verify:android && bun run verify:web",
36
+ "verify:ios": "xcodebuild -scheme CapgoCapacitorNativeMarket -destination generic/platform=iOS",
37
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
38
+ "verify:web": "bun run build",
39
+ "lint": "bun run eslint && bun run prettier -- --check && bun run swiftlint -- lint",
40
+ "fmt": "bun run eslint -- --fix && bun run prettier -- --write && bun run swiftlint -- --fix --format",
41
+ "eslint": "eslint .",
42
+ "prettier": "prettier-pretty-check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
43
+ "swiftlint": "node-swiftlint",
44
+ "docgen": "docgen --api NativeMarketPlugin --output-readme README.md --output-json dist/docs.json",
45
+ "build": "bun run clean && bun run docgen && tsc && rollup -c rollup.config.mjs",
46
+ "clean": "rimraf ./dist",
47
+ "watch": "tsc --watch",
48
+ "prepublishOnly": "bun run build",
49
+ "check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs"
50
+ },
51
+ "devDependencies": {
52
+ "@capacitor/android": "^8.0.0",
53
+ "@capacitor/core": "^8.0.0",
54
+ "@capacitor/cli": "^8.0.0",
55
+ "@capacitor/docgen": "^0.3.1",
56
+ "@capacitor/ios": "^8.0.0",
57
+ "@ionic/eslint-config": "^0.4.0",
58
+ "@ionic/prettier-config": "^4.0.0",
59
+ "@ionic/swiftlint-config": "^2.0.0",
60
+ "@types/node": "^24.10.1",
61
+ "eslint": "^8.57.1",
62
+ "eslint-plugin-import": "^2.31.0",
63
+ "husky": "^9.1.7",
64
+ "prettier": "^3.6.2",
65
+ "prettier-plugin-java": "^2.7.7",
66
+ "rimraf": "^6.1.0",
67
+ "rollup": "^4.53.2",
68
+ "swiftlint": "^2.0.0",
69
+ "typescript": "^5.9.3",
70
+ "prettier-pretty-check": "^0.2.0"
71
+ },
72
+ "peerDependencies": {
73
+ "@capacitor/core": ">=8.0.0"
74
+ },
75
+ "eslintConfig": {
76
+ "extends": "@ionic/eslint-config/recommended"
77
+ },
78
+ "prettier": "@ionic/prettier-config",
79
+ "swiftlint": "@ionic/swiftlint-config",
80
+ "capacitor": {
81
+ "ios": {
82
+ "src": "ios"
83
+ },
84
+ "android": {
85
+ "src": "android"
86
+ }
87
+ }
88
+ }