@cap-kit/rank 8.0.0
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/CapKitRank.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +574 -0
- package/android/build.gradle +110 -0
- package/android/src/main/AndroidManifest.xml +16 -0
- package/android/src/main/java/io/capkit/rank/RankConfig.kt +72 -0
- package/android/src/main/java/io/capkit/rank/RankError.kt +40 -0
- package/android/src/main/java/io/capkit/rank/RankImpl.kt +240 -0
- package/android/src/main/java/io/capkit/rank/RankPlugin.kt +312 -0
- package/android/src/main/java/io/capkit/rank/utils/RankLogger.kt +85 -0
- package/android/src/main/java/io/capkit/rank/utils/RankUtils.kt +14 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +441 -0
- package/dist/esm/definitions.d.ts +330 -0
- package/dist/esm/definitions.js +21 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +81 -0
- package/dist/esm/web.js +157 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +204 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +207 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/RankPlugin/RankConfig.swift +89 -0
- package/ios/Sources/RankPlugin/RankError.swift +49 -0
- package/ios/Sources/RankPlugin/RankImpl.swift +186 -0
- package/ios/Sources/RankPlugin/RankPlugin.swift +258 -0
- package/ios/Sources/RankPlugin/Utils/RankLogger.swift +69 -0
- package/ios/Sources/RankPlugin/Utils/RankUtils.swift +45 -0
- package/ios/Sources/RankPlugin/Version.swift +16 -0
- package/ios/Tests/RankPluginTests/RankPluginTests.swift +10 -0
- package/package.json +102 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capacitor configuration extension for the Rank plugin.
|
|
3
|
+
*
|
|
4
|
+
* Configuration values defined here can be provided under the `plugins.Rank`
|
|
5
|
+
* key inside `capacitor.config.ts`.
|
|
6
|
+
*
|
|
7
|
+
* These values are:
|
|
8
|
+
* - read natively at build/runtime
|
|
9
|
+
* - NOT accessible from JavaScript at runtime
|
|
10
|
+
* - treated as read-only static configuration
|
|
11
|
+
*/
|
|
12
|
+
declare module '@capacitor/cli' {
|
|
13
|
+
interface PluginsConfig {
|
|
14
|
+
/**
|
|
15
|
+
* Configuration options for the Rank plugin.
|
|
16
|
+
*/
|
|
17
|
+
Rank?: RankConfig;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Static configuration options for the Rank plugin.
|
|
22
|
+
*
|
|
23
|
+
* These values are defined in `capacitor.config.ts` and consumed
|
|
24
|
+
* exclusively by native code during plugin initialization.
|
|
25
|
+
*/
|
|
26
|
+
export interface RankConfig {
|
|
27
|
+
/**
|
|
28
|
+
* Enables verbose native logging.
|
|
29
|
+
*
|
|
30
|
+
* When enabled, additional debug information is printed
|
|
31
|
+
* to the native console (Logcat on Android, Xcode on iOS).
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
* @example true
|
|
35
|
+
* @since 8.0.0
|
|
36
|
+
*/
|
|
37
|
+
verboseLogging?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The Apple App ID used for App Store redirection on iOS.
|
|
40
|
+
* Example: '123456789'
|
|
41
|
+
* * @since 8.0.0
|
|
42
|
+
*/
|
|
43
|
+
appleAppId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The Android Package Name used for Play Store redirection.
|
|
46
|
+
* Example: 'com.example.app'
|
|
47
|
+
* * @since 8.0.0
|
|
48
|
+
*/
|
|
49
|
+
androidPackageName?: string;
|
|
50
|
+
/**
|
|
51
|
+
* If true, the `requestReview` method will resolve immediately
|
|
52
|
+
* without waiting for the native OS review flow to complete.
|
|
53
|
+
* * @default false
|
|
54
|
+
* @since 8.0.0
|
|
55
|
+
*/
|
|
56
|
+
fireAndForget?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Standardized error codes used by the Rank plugin.
|
|
60
|
+
*
|
|
61
|
+
* These codes are returned as part of structured error objects
|
|
62
|
+
* and allow consumers to implement programmatic error handling.
|
|
63
|
+
*
|
|
64
|
+
* @since 8.0.0
|
|
65
|
+
*/
|
|
66
|
+
export declare enum RankErrorCode {
|
|
67
|
+
/** The device does not have the requested hardware or the API is unavailable. */
|
|
68
|
+
UNAVAILABLE = "UNAVAILABLE",
|
|
69
|
+
/** The user denied a required permission or the feature is disabled. */
|
|
70
|
+
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
71
|
+
/** The Rank plugin failed to initialize (e.g., native SDK error). */
|
|
72
|
+
INIT_FAILED = "INIT_FAILED",
|
|
73
|
+
/** The requested operation or type is not valid or supported. */
|
|
74
|
+
UNKNOWN_TYPE = "UNKNOWN_TYPE"
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Diagnostic result for Android In-App Review availability.
|
|
78
|
+
*
|
|
79
|
+
* This result describes whether the Google Play Review
|
|
80
|
+
* flow can actually be displayed in the current environment.
|
|
81
|
+
*
|
|
82
|
+
* @since 8.0.0
|
|
83
|
+
*/
|
|
84
|
+
export interface ReviewEnvironmentResult {
|
|
85
|
+
/**
|
|
86
|
+
* True if the environment supports showing the review dialog.
|
|
87
|
+
*/
|
|
88
|
+
canRequestReview: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Optional diagnostic reason when the review dialog cannot be shown.
|
|
91
|
+
*/
|
|
92
|
+
reason?: 'PLAY_STORE_NOT_AVAILABLE' | 'NOT_INSTALLED_FROM_PLAY_STORE';
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Options for the `requestReview` method.
|
|
96
|
+
*/
|
|
97
|
+
export interface ReviewOptions {
|
|
98
|
+
/**
|
|
99
|
+
* Override the global configuration to determine if the promise
|
|
100
|
+
* should resolve immediately or wait for the native flow.
|
|
101
|
+
*/
|
|
102
|
+
fireAndForget?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Options for the `openStore` method.
|
|
106
|
+
*/
|
|
107
|
+
export interface StoreOptions {
|
|
108
|
+
/**
|
|
109
|
+
* Runtime override for the Apple App ID on iOS.
|
|
110
|
+
*/
|
|
111
|
+
appId?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Runtime override for the Android Package Name.
|
|
114
|
+
*/
|
|
115
|
+
packageName?: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Result object returned by the `isAvailable()` method.
|
|
119
|
+
*/
|
|
120
|
+
export interface AvailabilityResult {
|
|
121
|
+
/**
|
|
122
|
+
* Indicates whether the native In-App Review UI is available.
|
|
123
|
+
*/
|
|
124
|
+
value: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Result object returned by the `getPluginVersion()` method.
|
|
128
|
+
*/
|
|
129
|
+
export interface PluginVersionResult {
|
|
130
|
+
/**
|
|
131
|
+
* The native plugin version string.
|
|
132
|
+
*/
|
|
133
|
+
version: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Structured error object returned by Rank plugin operations.
|
|
137
|
+
*
|
|
138
|
+
* This object allows consumers to handle errors without relying
|
|
139
|
+
* on exception-based control flow.
|
|
140
|
+
*/
|
|
141
|
+
export interface RankError {
|
|
142
|
+
/**
|
|
143
|
+
* Human-readable error description.
|
|
144
|
+
*/
|
|
145
|
+
message: string;
|
|
146
|
+
/**
|
|
147
|
+
* Machine-readable error code.
|
|
148
|
+
*/
|
|
149
|
+
code: RankErrorCode;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Public JavaScript API for the Rank Capacitor plugin.
|
|
153
|
+
*
|
|
154
|
+
* This interface defines a stable, platform-agnostic API.
|
|
155
|
+
* All methods behave consistently across Android, iOS, and Web.
|
|
156
|
+
*/
|
|
157
|
+
export interface RankPlugin {
|
|
158
|
+
/**
|
|
159
|
+
* Checks if the native In-App Review UI can be displayed.
|
|
160
|
+
* On Android, it verifies Google Play Services availability.
|
|
161
|
+
* On iOS, it checks the OS version compatibility.
|
|
162
|
+
*
|
|
163
|
+
* @returns A promise resolving to an AvailabilityResult object.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* const { value } = await Rank.isAvailable();
|
|
168
|
+
* if (value) {
|
|
169
|
+
* // Show review prompt or related UI
|
|
170
|
+
* } else {
|
|
171
|
+
* // Fallback behavior for unsupported platforms
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @since 8.0.0
|
|
176
|
+
*/
|
|
177
|
+
isAvailable(): Promise<AvailabilityResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Performs a diagnostic check to determine whether the
|
|
180
|
+
* Google Play In-App Review dialog can be displayed.
|
|
181
|
+
*
|
|
182
|
+
* This does NOT trigger the review flow.
|
|
183
|
+
* Android-only. On other platforms, it resolves as unavailable.
|
|
184
|
+
*
|
|
185
|
+
* @since 8.0.0
|
|
186
|
+
*/
|
|
187
|
+
checkReviewEnvironment(): Promise<ReviewEnvironmentResult>;
|
|
188
|
+
/**
|
|
189
|
+
* Requests the display of the native review popup.
|
|
190
|
+
* On Web, this operation calls unimplemented().
|
|
191
|
+
* @param options Optional review configuration overrides.
|
|
192
|
+
*
|
|
193
|
+
* @returns A promise that resolves when the request is sent or completed.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* // Basic usage with default configuration
|
|
198
|
+
* await Rank.requestReview();
|
|
199
|
+
*
|
|
200
|
+
* // Usage with fire-and-forget behavior
|
|
201
|
+
* await Rank.requestReview({ fireAndForget: true });
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @since 8.0.0
|
|
205
|
+
*/
|
|
206
|
+
requestReview(options?: ReviewOptions): Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Opens the App Store product page internally (iOS) or redirects to the Store (Android/Web).
|
|
209
|
+
* @param options Store identification.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* // On iOS, this will open an internal App Store overlay.
|
|
214
|
+
* await Rank.presentProductPage({
|
|
215
|
+
* appId: '123456789' // iOS App ID for URL generation
|
|
216
|
+
* });
|
|
217
|
+
*
|
|
218
|
+
* // On Android, this will redirect to the Play Store.
|
|
219
|
+
* await Rank.presentProductPage({
|
|
220
|
+
* packageName: 'com.example.app' // Android Package Name for URL generation
|
|
221
|
+
* });
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @since 8.0.0
|
|
225
|
+
*/
|
|
226
|
+
presentProductPage(options?: StoreOptions): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Opens the app's page in the App Store (iOS) or Play Store (Android).
|
|
229
|
+
* On Web, it performs a URL redirect if parameters are provided.
|
|
230
|
+
* @param options Optional store identification overrides.
|
|
231
|
+
*
|
|
232
|
+
* @returns A promise that resolves when the store application is launched.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* // On Web, this will open the store page in a new tab if identifiers are provided.
|
|
237
|
+
* await Rank.openStore({
|
|
238
|
+
* appId: '123456789', // iOS App ID for URL generation
|
|
239
|
+
* packageName: 'com.example.app' // Android Package Name for URL generation
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @since 8.0.0
|
|
244
|
+
*/
|
|
245
|
+
openStore(options?: StoreOptions): Promise<void>;
|
|
246
|
+
/**
|
|
247
|
+
* Opens the App Store listing page for a specific app.
|
|
248
|
+
* If no appId is provided, it uses the one from the plugin configuration.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* // Opens the store listing page.
|
|
253
|
+
* // Uses the provided appId or falls back to the one in capacitor.config.ts
|
|
254
|
+
* await Rank.openStoreListing({
|
|
255
|
+
* appId: '123456789'
|
|
256
|
+
* });
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @since 8.0.0
|
|
260
|
+
*/
|
|
261
|
+
openStoreListing(options?: {
|
|
262
|
+
appId?: string;
|
|
263
|
+
}): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Performs a search in the app store for the given terms.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* // Searches the store for specific terms.
|
|
270
|
+
* // Android: market://search | iOS: itms-apps search
|
|
271
|
+
* await Rank.search({
|
|
272
|
+
* terms: 'Capacitor Plugins'
|
|
273
|
+
* });
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* @since 8.0.0
|
|
277
|
+
*/
|
|
278
|
+
search(options: {
|
|
279
|
+
terms: string;
|
|
280
|
+
}): Promise<void>;
|
|
281
|
+
/**
|
|
282
|
+
* Opens the developer's page in the app store.
|
|
283
|
+
* @param options.devId On Android, this is the developer ID (numeric or string). On iOS, this is ignored.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```ts
|
|
287
|
+
* // Navigates to a developer or brand page.
|
|
288
|
+
* await Rank.openDevPage({
|
|
289
|
+
* devId: '543216789'
|
|
290
|
+
* });
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @since 8.0.0
|
|
294
|
+
*/
|
|
295
|
+
openDevPage(options: {
|
|
296
|
+
devId: string;
|
|
297
|
+
}): Promise<void>;
|
|
298
|
+
/**
|
|
299
|
+
* Opens a specific app collection (Android Only).
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* // Opens a curated collection (Android only).
|
|
304
|
+
* await Rank.openCollection({
|
|
305
|
+
* name: 'editors_choice'
|
|
306
|
+
* });
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* @since 8.0.0
|
|
310
|
+
*/
|
|
311
|
+
openCollection(options: {
|
|
312
|
+
name: string;
|
|
313
|
+
}): Promise<void>;
|
|
314
|
+
/**
|
|
315
|
+
* Returns the native plugin version.
|
|
316
|
+
*
|
|
317
|
+
* The returned version corresponds to the native implementation
|
|
318
|
+
* bundled with the application.
|
|
319
|
+
*
|
|
320
|
+
* @returns A promise resolving to the plugin version.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* const { version } = await Rank.getPluginVersion();
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* @since 8.0.0
|
|
328
|
+
*/
|
|
329
|
+
getPluginVersion(): Promise<PluginVersionResult>;
|
|
330
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="@capacitor/cli" />
|
|
2
|
+
/**
|
|
3
|
+
* Standardized error codes used by the Rank plugin.
|
|
4
|
+
*
|
|
5
|
+
* These codes are returned as part of structured error objects
|
|
6
|
+
* and allow consumers to implement programmatic error handling.
|
|
7
|
+
*
|
|
8
|
+
* @since 8.0.0
|
|
9
|
+
*/
|
|
10
|
+
export var RankErrorCode;
|
|
11
|
+
(function (RankErrorCode) {
|
|
12
|
+
/** The device does not have the requested hardware or the API is unavailable. */
|
|
13
|
+
RankErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
|
|
14
|
+
/** The user denied a required permission or the feature is disabled. */
|
|
15
|
+
RankErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
|
|
16
|
+
/** The Rank plugin failed to initialize (e.g., native SDK error). */
|
|
17
|
+
RankErrorCode["INIT_FAILED"] = "INIT_FAILED";
|
|
18
|
+
/** The requested operation or type is not valid or supported. */
|
|
19
|
+
RankErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
|
|
20
|
+
})(RankErrorCode || (RankErrorCode = {}));
|
|
21
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAgExC;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,aASX;AATD,WAAY,aAAa;IACvB,iFAAiF;IACjF,4CAA2B,CAAA;IAC3B,wEAAwE;IACxE,wDAAuC,CAAA;IACvC,qEAAqE;IACrE,4CAA2B,CAAA;IAC3B,iEAAiE;IACjE,8CAA6B,CAAA;AAC/B,CAAC,EATW,aAAa,KAAb,aAAa,QASxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* This file exports the Rank and registers it with Capacitor.
|
|
4
|
+
* It acts as the main entry point for accessing the plugin's functionality
|
|
5
|
+
* across different platforms, including web.
|
|
6
|
+
*/
|
|
7
|
+
import { RankPlugin } from './definitions';
|
|
8
|
+
/**
|
|
9
|
+
* Main entry point for the Rank Capacitor plugin.
|
|
10
|
+
*
|
|
11
|
+
* This file registers the plugin with Capacitor and exports
|
|
12
|
+
* both the runtime instance and the public TypeScript types.
|
|
13
|
+
*/
|
|
14
|
+
declare const Rank: RankPlugin;
|
|
15
|
+
export * from './definitions';
|
|
16
|
+
export { Rank };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* This file exports the Rank and registers it with Capacitor.
|
|
4
|
+
* It acts as the main entry point for accessing the plugin's functionality
|
|
5
|
+
* across different platforms, including web.
|
|
6
|
+
*/
|
|
7
|
+
import { registerPlugin } from '@capacitor/core';
|
|
8
|
+
/**
|
|
9
|
+
* Main entry point for the Rank Capacitor plugin.
|
|
10
|
+
*
|
|
11
|
+
* This file registers the plugin with Capacitor and exports
|
|
12
|
+
* both the runtime instance and the public TypeScript types.
|
|
13
|
+
*/
|
|
14
|
+
const Rank = registerPlugin('Rank', {
|
|
15
|
+
web: () => import('./web').then((m) => new m.RankWeb()),
|
|
16
|
+
});
|
|
17
|
+
export * from './definitions';
|
|
18
|
+
export { Rank };
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD;;;;;GAKG;AACH,MAAM,IAAI,GAAG,cAAc,CAAa,MAAM,EAAE;IAC9C,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;CACxD,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import { RankPlugin, PluginVersionResult, StoreOptions, ReviewEnvironmentResult } from './definitions';
|
|
3
|
+
/**
|
|
4
|
+
* Web implementation of the Rank plugin.
|
|
5
|
+
*
|
|
6
|
+
* This implementation exists primarily to satisfy Capacitor's
|
|
7
|
+
* multi-platform contract and to allow usage in browser-based
|
|
8
|
+
* environments.
|
|
9
|
+
*
|
|
10
|
+
* Native-only features like the In-App Review prompt are unavailable on Web.
|
|
11
|
+
*/
|
|
12
|
+
export declare class RankWeb extends WebPlugin implements RankPlugin {
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* On Web, native In-App Review is never available.
|
|
16
|
+
*/
|
|
17
|
+
isAvailable(): Promise<{
|
|
18
|
+
value: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* On Web, the review environment is not available, so this method returns a default result.
|
|
22
|
+
*/
|
|
23
|
+
checkReviewEnvironment(): Promise<ReviewEnvironmentResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Requests the display of the native review popup.
|
|
26
|
+
*
|
|
27
|
+
* On Web, this feature is not available.
|
|
28
|
+
*/
|
|
29
|
+
requestReview(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* On Web, redirects to the store URL as an internal overlay is not possible.
|
|
32
|
+
*/
|
|
33
|
+
presentProductPage(options?: StoreOptions): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Opens the app's page in the App Store or Play Store via URL redirect.
|
|
36
|
+
* @description Detects the user's platform to provide the correct store link.
|
|
37
|
+
* @param options Store identification overrides including appId for iOS or packageName for Android.
|
|
38
|
+
*/
|
|
39
|
+
openStore(options?: StoreOptions): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Opens the App Store listing page for a specific app via URL redirect.
|
|
42
|
+
* @param options Store identification options.
|
|
43
|
+
*/
|
|
44
|
+
openStoreListing(options?: {
|
|
45
|
+
appId?: string;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Redirects to the developer's page in the store.
|
|
49
|
+
* @param options.devId The developer ID to navigate to.
|
|
50
|
+
*/
|
|
51
|
+
openDevPage(options: {
|
|
52
|
+
devId: string;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* On Web, collection navigation is not supported, so this method logs a warning.
|
|
56
|
+
* @param options Collection identification (not used on Web).
|
|
57
|
+
* @description This method is a no-op on Web and serves as a placeholder for potential future functionality.
|
|
58
|
+
*/
|
|
59
|
+
openCollection(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* On Web, search navigation is not supported, so this method logs a warning and opens a generic search URL.
|
|
62
|
+
* @param options Search terms for finding the app in the store (not used on Web).
|
|
63
|
+
* @description Redirects to a generic search page on the respective store as a fallback.
|
|
64
|
+
*/
|
|
65
|
+
search(options: {
|
|
66
|
+
terms: string;
|
|
67
|
+
}): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Generates the appropriate store URL based on user agent and provided options.
|
|
70
|
+
* * @param options Store options containing identifiers.
|
|
71
|
+
* @returns A string representing the full store URL.
|
|
72
|
+
*/
|
|
73
|
+
private getStoreUrl;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the plugin version.
|
|
76
|
+
*
|
|
77
|
+
* On the Web, this value represents the JavaScript package version
|
|
78
|
+
* rather than a native implementation.
|
|
79
|
+
*/
|
|
80
|
+
getPluginVersion(): Promise<PluginVersionResult>;
|
|
81
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
/**
|
|
3
|
+
* Web implementation of the Rank plugin.
|
|
4
|
+
*
|
|
5
|
+
* This implementation exists primarily to satisfy Capacitor's
|
|
6
|
+
* multi-platform contract and to allow usage in browser-based
|
|
7
|
+
* environments.
|
|
8
|
+
*
|
|
9
|
+
* Native-only features like the In-App Review prompt are unavailable on Web.
|
|
10
|
+
*/
|
|
11
|
+
export class RankWeb extends WebPlugin {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
}
|
|
15
|
+
// --- Availability ---
|
|
16
|
+
/**
|
|
17
|
+
* On Web, native In-App Review is never available.
|
|
18
|
+
*/
|
|
19
|
+
async isAvailable() {
|
|
20
|
+
return { value: false };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* On Web, the review environment is not available, so this method returns a default result.
|
|
24
|
+
*/
|
|
25
|
+
async checkReviewEnvironment() {
|
|
26
|
+
return {
|
|
27
|
+
canRequestReview: false,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// --- In-App Review ---
|
|
31
|
+
/**
|
|
32
|
+
* Requests the display of the native review popup.
|
|
33
|
+
*
|
|
34
|
+
* On Web, this feature is not available.
|
|
35
|
+
*/
|
|
36
|
+
async requestReview() {
|
|
37
|
+
throw this.unimplemented('In-App Review is not available on Web.');
|
|
38
|
+
}
|
|
39
|
+
// --- Product Page Navigation ---
|
|
40
|
+
/**
|
|
41
|
+
* On Web, redirects to the store URL as an internal overlay is not possible.
|
|
42
|
+
*/
|
|
43
|
+
async presentProductPage(options) {
|
|
44
|
+
return this.openStore(options);
|
|
45
|
+
}
|
|
46
|
+
// --- Store Navigation ---
|
|
47
|
+
/**
|
|
48
|
+
* Opens the app's page in the App Store or Play Store via URL redirect.
|
|
49
|
+
* @description Detects the user's platform to provide the correct store link.
|
|
50
|
+
* @param options Store identification overrides including appId for iOS or packageName for Android.
|
|
51
|
+
*/
|
|
52
|
+
async openStore(options) {
|
|
53
|
+
if (!(options === null || options === void 0 ? void 0 : options.appId) && !(options === null || options === void 0 ? void 0 : options.packageName)) {
|
|
54
|
+
console.warn('Rank: No App ID or Package Name provided. Store redirect skipped.');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const url = this.getStoreUrl(options);
|
|
58
|
+
if (!url) {
|
|
59
|
+
// URL construction failed due to missing or invalid identifiers
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
window.open(url, '_blank');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Opens the App Store listing page for a specific app via URL redirect.
|
|
66
|
+
* @param options Store identification options.
|
|
67
|
+
*/
|
|
68
|
+
async openStoreListing(options) {
|
|
69
|
+
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
70
|
+
if (isIOS && (options === null || options === void 0 ? void 0 : options.appId)) {
|
|
71
|
+
window.open(RankStoreUtils.appStoreUrl(options.appId), '_blank');
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.warn('Rank: openStoreListing is primarily intended for iOS identifiers on Web.');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Redirects to the developer's page in the store.
|
|
79
|
+
* @param options.devId The developer ID to navigate to.
|
|
80
|
+
*/
|
|
81
|
+
async openDevPage(options) {
|
|
82
|
+
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
83
|
+
const url = isIOS
|
|
84
|
+
? RankStoreUtils.appStoreSearchUrl(options.devId) // iOS uses search for dev pages often
|
|
85
|
+
: RankStoreUtils.playStoreDevUrl(options.devId);
|
|
86
|
+
window.open(url, '_blank');
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* On Web, collection navigation is not supported, so this method logs a warning.
|
|
90
|
+
* @param options Collection identification (not used on Web).
|
|
91
|
+
* @description This method is a no-op on Web and serves as a placeholder for potential future functionality.
|
|
92
|
+
*/
|
|
93
|
+
async openCollection() {
|
|
94
|
+
console.warn('Rank: openCollection is not available on Web.');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* On Web, search navigation is not supported, so this method logs a warning and opens a generic search URL.
|
|
98
|
+
* @param options Search terms for finding the app in the store (not used on Web).
|
|
99
|
+
* @description Redirects to a generic search page on the respective store as a fallback.
|
|
100
|
+
*/
|
|
101
|
+
async search(options) {
|
|
102
|
+
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
103
|
+
const url = isIOS
|
|
104
|
+
? RankStoreUtils.appStoreSearchUrl(options.terms)
|
|
105
|
+
: RankStoreUtils.playStoreSearchUrl(options.terms);
|
|
106
|
+
window.open(url, '_blank');
|
|
107
|
+
}
|
|
108
|
+
// --- Internal Helpers ---
|
|
109
|
+
/**
|
|
110
|
+
* Generates the appropriate store URL based on user agent and provided options.
|
|
111
|
+
* * @param options Store options containing identifiers.
|
|
112
|
+
* @returns A string representing the full store URL.
|
|
113
|
+
*/
|
|
114
|
+
getStoreUrl(options) {
|
|
115
|
+
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
116
|
+
if (isIOS && options.appId) {
|
|
117
|
+
return RankStoreUtils.appStoreUrl(options.appId);
|
|
118
|
+
}
|
|
119
|
+
return RankStoreUtils.playStoreUrl(options.packageName);
|
|
120
|
+
}
|
|
121
|
+
// --- Plugin Info ---
|
|
122
|
+
/**
|
|
123
|
+
* Returns the plugin version.
|
|
124
|
+
*
|
|
125
|
+
* On the Web, this value represents the JavaScript package version
|
|
126
|
+
* rather than a native implementation.
|
|
127
|
+
*/
|
|
128
|
+
async getPluginVersion() {
|
|
129
|
+
return { version: 'web' };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Internal utility helpers for Store URL construction.
|
|
134
|
+
* Not part of the public API.
|
|
135
|
+
*/
|
|
136
|
+
class RankStoreUtils {
|
|
137
|
+
static appStoreUrl(appId) {
|
|
138
|
+
return `https://apps.apple.com/app/id${appId}`;
|
|
139
|
+
}
|
|
140
|
+
static appStoreSearchUrl(terms) {
|
|
141
|
+
return `https://apps.apple.com/search?term=${encodeURIComponent(terms)}`;
|
|
142
|
+
}
|
|
143
|
+
static playStoreUrl(packageName) {
|
|
144
|
+
if (!packageName || packageName.trim().length === 0) {
|
|
145
|
+
console.warn('Rank: Missing Android packageName. Cannot construct Play Store URL.');
|
|
146
|
+
return '';
|
|
147
|
+
}
|
|
148
|
+
return `https://play.google.com/store/apps/details?id=${packageName}`;
|
|
149
|
+
}
|
|
150
|
+
static playStoreDevUrl(devId) {
|
|
151
|
+
return `https://play.google.com/store/apps/dev?id=${devId}`;
|
|
152
|
+
}
|
|
153
|
+
static playStoreSearchUrl(terms) {
|
|
154
|
+
return `https://play.google.com/store/search?q=${encodeURIComponent(terms)}&c=apps`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C;;;;;;;;GAQG;AACH,MAAM,OAAO,OAAQ,SAAQ,SAAS;IACpC;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,uBAAuB;IAEvB;;OAEG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IA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