@app-swiss-knife/react-native-sdk 0.1.1 → 0.2.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/README.md +51 -0
- package/android/build.gradle +7 -0
- package/android/consumer-rules.pro +64 -0
- package/android/src/main/java/com/swissknife/purchases/Conversions.kt +85 -0
- package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +37 -30
- package/android/vendor/java/com/appswissknife/SwissKnife.kt +219 -51
- package/android/vendor/java/com/appswissknife/attribution/Attribution.kt +177 -25
- package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +1 -1
- package/android/vendor/java/com/appswissknife/identity/Identity.kt +15 -0
- package/android/vendor/java/com/appswissknife/net/IngestClient.kt +1 -1
- package/ios/SwissKnifePurchases.m +8 -0
- package/ios/SwissKnifePurchases.swift +35 -0
- package/ios/vendor/SwissKnifeiOS/Attribution/Attribution.swift +25 -7
- package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +1 -1
- package/ios/vendor/SwissKnifeiOS/Identity/Identity.swift +8 -2
- package/ios/vendor/SwissKnifeiOS/Net/BackendHttpClient.swift +32 -1
- package/ios/vendor/SwissKnifeiOS/Services/EntitlementsService.swift +35 -5
- package/ios/vendor/SwissKnifeiOS/Services/PurchaseService.swift +39 -22
- package/ios/vendor/SwissKnifeiOS/SwissKnife+DeviceID.swift +12 -2
- package/ios/vendor/SwissKnifeiOS/SwissKnife.swift +270 -32
- package/lib/commonjs/identity.js +59 -4
- package/lib/commonjs/identity.js.map +1 -1
- package/lib/commonjs/native/spec.js.map +1 -1
- package/lib/commonjs/purchases.js +95 -3
- package/lib/commonjs/purchases.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/identity.js +59 -4
- package/lib/module/identity.js.map +1 -1
- package/lib/module/native/spec.js.map +1 -1
- package/lib/module/purchases.js +95 -3
- package/lib/module/purchases.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/identity.d.ts +30 -4
- package/lib/typescript/commonjs/identity.d.ts.map +1 -1
- package/lib/typescript/commonjs/native/spec.d.ts +27 -0
- package/lib/typescript/commonjs/native/spec.d.ts.map +1 -1
- package/lib/typescript/commonjs/purchases.d.ts +46 -1
- package/lib/typescript/commonjs/purchases.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +11 -2
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/module/identity.d.ts +30 -4
- package/lib/typescript/module/identity.d.ts.map +1 -1
- package/lib/typescript/module/native/spec.d.ts +27 -0
- package/lib/typescript/module/native/spec.d.ts.map +1 -1
- package/lib/typescript/module/purchases.d.ts +46 -1
- package/lib/typescript/module/purchases.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +11 -2
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/identity.ts +63 -4
- package/src/native/spec.ts +30 -0
- package/src/purchases.ts +103 -4
- package/src/types.ts +11 -2
package/README.md
CHANGED
|
@@ -117,6 +117,57 @@ const flags = await client.get("/api/sdk/flags/evaluate", {
|
|
|
117
117
|
});
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
## Already using another IAP library? Use `configureCore`
|
|
121
|
+
|
|
122
|
+
`Purchases.configure(...)` sets up two independent things: the **core** (event
|
|
123
|
+
ingest, `Identity`, `Attribution`, subscriber attributes) and the **purchase
|
|
124
|
+
engine** (StoreKit 2 on iOS, Google Play Billing on Android).
|
|
125
|
+
|
|
126
|
+
The purchase engine is not passive. On iOS it starts a process-wide
|
|
127
|
+
`StoreKit.Transaction.updates` observer whose handler calls
|
|
128
|
+
`transaction.finish()`; on Android it builds a `BillingClient` with its own
|
|
129
|
+
`PurchasesUpdatedListener`. If RevenueCat (or your own StoreKit/Billing code)
|
|
130
|
+
already owns purchases, two observers will race to finish the same renewal.
|
|
131
|
+
|
|
132
|
+
So the two halves are separately callable:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import {
|
|
136
|
+
Purchases,
|
|
137
|
+
Identity,
|
|
138
|
+
Attribution,
|
|
139
|
+
Analytics,
|
|
140
|
+
} from "@app-swiss-knife/react-native-sdk";
|
|
141
|
+
|
|
142
|
+
// Analytics + identity + attribution. No StoreKit observer. No BillingClient.
|
|
143
|
+
// No install registered as a side effect.
|
|
144
|
+
Purchases.configureCore({
|
|
145
|
+
apiKey: "sk_...",
|
|
146
|
+
proxyURL: "https://your-swiss-knife-host",
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
await Identity.logIn("user_42");
|
|
150
|
+
await Attribution.registerInstall(); // explicit — core never does this for you
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- **Analytics only?** `Analytics.init({ apiKey, serverURL })` already wires core
|
|
154
|
+
natively — identity and attribution work from that call alone. Reach for
|
|
155
|
+
`configureCore` when you also want to pass an `appUserID`, an attribution
|
|
156
|
+
configuration, or a log level up front.
|
|
157
|
+
- **`Purchases.configure(...)` is unchanged** — it is exactly core + purchases,
|
|
158
|
+
including the first-launch install registration
|
|
159
|
+
(`sendInstallOnFirstLaunch`, default `true`). Existing integrations need no
|
|
160
|
+
changes.
|
|
161
|
+
- `Purchases.isConfigured()` reports the **purchase engine** and stays `false`
|
|
162
|
+
in a core-only app; `Purchases.isCoreConfigured()` reports the core. Both read
|
|
163
|
+
the answer from native — which is what makes `isCoreConfigured()` return
|
|
164
|
+
`true` in an `Analytics.init`-only app, where no JS configure call ever
|
|
165
|
+
happened. Neither ever throws or rejects: if the native module is not linked
|
|
166
|
+
(Expo Go, a build without `pod install` / a Gradle sync, web) they both
|
|
167
|
+
resolve `false`, because an unlinked module cannot have configured anything.
|
|
168
|
+
- Native equivalents: `SwissKnife.configureCore(...)` /
|
|
169
|
+
`SwissKnife.configurePurchases(...)` on both iOS and Android.
|
|
170
|
+
|
|
120
171
|
## IDFA/GAID Collection (Advertising ID)
|
|
121
172
|
|
|
122
173
|
The SDK can collect the device advertising ID (IDFA on iOS, GAID on Android) for deterministic attribution matching. This is optional — if not configured, attribution falls back to fingerprint/referrer matching.
|
package/android/build.gradle
CHANGED
|
@@ -22,6 +22,13 @@ android {
|
|
|
22
22
|
defaultConfig {
|
|
23
23
|
minSdkVersion safeExtGet("minSdkVersion", 24)
|
|
24
24
|
targetSdkVersion safeExtGet("targetSdkVersion", 35)
|
|
25
|
+
|
|
26
|
+
// Ship R8/ProGuard keeps INSIDE the AAR so a consumer's minified release
|
|
27
|
+
// build cannot strip or rename the bridge. Without this a `release` build
|
|
28
|
+
// with `minifyEnabled true` can drop the @ReactMethod methods (only ever
|
|
29
|
+
// reached reflectively) and the module fails at runtime with no build-time
|
|
30
|
+
// signal. Same wiring expo-modules-core uses. See consumer-rules.pro.
|
|
31
|
+
consumerProguardFiles "consumer-rules.pro"
|
|
25
32
|
}
|
|
26
33
|
compileOptions {
|
|
27
34
|
sourceCompatibility JavaVersion.VERSION_17
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# packages/react-native-sdk/android/consumer-rules.pro
|
|
2
|
+
#
|
|
3
|
+
# Consumer R8/ProGuard rules for @app-swiss-knife/react-native-sdk. Wired via
|
|
4
|
+
# `consumerProguardFiles` in android/build.gradle, so AGP merges them into the
|
|
5
|
+
# rule set of any app that links this AAR — the app author has to do nothing.
|
|
6
|
+
#
|
|
7
|
+
# Every rule here is scoped to `com.swissknife.**` (the RN bridge) or
|
|
8
|
+
# `com.appswissknife.**` (the vendored Swiss Knife Android SDK). We deliberately
|
|
9
|
+
# do NOT ship blanket `class *` rules: consumer rules apply to the consumer's
|
|
10
|
+
# ENTIRE app, and a library has no business widening keeps over code it does not
|
|
11
|
+
# own. React Native's own AAR already ships the global equivalents
|
|
12
|
+
# (`-keep class * implements com.facebook.react.bridge.NativeModule { *; }`,
|
|
13
|
+
# `@ReactProp` members, `com.facebook.react.bridge.**`); the rules below are the
|
|
14
|
+
# narrowly-scoped versions of the ones that protect OUR classes, so this SDK
|
|
15
|
+
# survives minification on its own merits rather than by relying on a
|
|
16
|
+
# transitive dependency's rule file staying the way it is today.
|
|
17
|
+
#
|
|
18
|
+
# Reference points used when writing this file (all present in the dependency
|
|
19
|
+
# tree): react-native/ReactAndroid/proguard-rules.pro and
|
|
20
|
+
# expo-modules-core/android/proguard-rules.pro (wired the same way, via
|
|
21
|
+
# `defaultConfig { consumerProguardFiles 'proguard-rules.pro' }`).
|
|
22
|
+
|
|
23
|
+
# ── React Native bridge ───────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
# The annotation itself must survive, otherwise the -keepclassmembers rules
|
|
26
|
+
# below have nothing to match on. Same reason React Native keeps @DoNotStrip —
|
|
27
|
+
# see http://sourceforge.net/p/proguard/bugs/466/
|
|
28
|
+
-keep,allowobfuscation @interface com.facebook.react.bridge.ReactMethod
|
|
29
|
+
|
|
30
|
+
# Native modules. The legacy bridge builds its method table by reflecting over
|
|
31
|
+
# the module class and filtering declared methods by @ReactMethod, and
|
|
32
|
+
# `getName()` supplies the JS-visible module name that `NativeModules[...]` /
|
|
33
|
+
# `TurboModuleRegistry.get(...)` look up. Renaming or stripping either breaks
|
|
34
|
+
# the module at runtime with no compile-time signal.
|
|
35
|
+
-keep class com.swissknife.** implements com.facebook.react.bridge.NativeModule { *; }
|
|
36
|
+
-keepclassmembers class com.swissknife.** {
|
|
37
|
+
@com.facebook.react.bridge.ReactMethod <methods>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# ReactPackage implementations are named by the generated `PackageList` (and by
|
|
41
|
+
# `react-native.config.js` -> `packageInstance`), which is code the app builds
|
|
42
|
+
# rather than code R8 can see a reference from in every configuration.
|
|
43
|
+
-keep class com.swissknife.** implements com.facebook.react.ReactPackage { *; }
|
|
44
|
+
|
|
45
|
+
# ── Vendored Swiss Knife Android SDK (com.appswissknife.**) ───────────────────
|
|
46
|
+
|
|
47
|
+
# WorkManager instantiates workers reflectively, by class name, from a record it
|
|
48
|
+
# persisted in its own database — so a worker enqueued before an app update can
|
|
49
|
+
# be resurrected after it. androidx.work ships an equivalent global rule; this
|
|
50
|
+
# is the scoped restatement, and it is the one keep in this file whose absence
|
|
51
|
+
# produces a *silent* failure (analytics/attributes stop flushing) rather than a
|
|
52
|
+
# crash.
|
|
53
|
+
-keep class com.appswissknife.** extends androidx.work.ListenableWorker {
|
|
54
|
+
public <init>(android.content.Context, androidx.work.WorkerParameters);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# okhttp3 is a `compileOnly` dependency: `SKPerformanceInterceptor` and
|
|
58
|
+
# `SKBreadcrumbInterceptor` implement `okhttp3.Interceptor` so hosts that use
|
|
59
|
+
# okhttp can install them, but the SDK never requires okhttp at runtime. In an
|
|
60
|
+
# app that does not bring okhttp, R8 in full mode reports the missing supertype
|
|
61
|
+
# as an ERROR and fails the build. React Native itself always pulls okhttp in,
|
|
62
|
+
# so this is a belt-and-braces rule for non-RN/stripped consumers — but it costs
|
|
63
|
+
# nothing and turns a hard build failure into a no-op.
|
|
64
|
+
-dontwarn okhttp3.**
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
// packages/react-native-sdk/android/src/main/java/com/swissknife/purchases/Conversions.kt
|
|
2
|
+
//
|
|
3
|
+
// Pure marshalling between the RN bridge's ReadableMap / typed native models
|
|
4
|
+
// and the shapes each side expects. Everything here is top-level and free of
|
|
5
|
+
// ReactApplicationContext ON PURPOSE: `ReactContextBaseJavaModule` cannot be
|
|
6
|
+
// constructed in a JVM unit test (`null as ReactApplicationContext` throws), so
|
|
7
|
+
// any helper that lives as an instance method on SwissKnifePurchasesModule is
|
|
8
|
+
// effectively untestable. Keep new pure conversions here.
|
|
2
9
|
package com.swissknife.purchases
|
|
3
10
|
|
|
11
|
+
import com.appswissknife.attribution.Attribution
|
|
12
|
+
import com.appswissknife.models.PurchasesErrorCode
|
|
4
13
|
import com.facebook.react.bridge.ReadableMap
|
|
5
14
|
|
|
6
15
|
// Subscriber attributes are string|null. Drops non-string values defensively.
|
|
@@ -13,3 +22,79 @@ fun ReadableMap.toStringMap(): Map<String, String?> {
|
|
|
13
22
|
}
|
|
14
23
|
return out
|
|
15
24
|
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* `ReadableMap.getBoolean` throws on a missing key and returns `false` for an
|
|
28
|
+
* explicit JS `null`/`undefined`, so every optional boolean has to be read
|
|
29
|
+
* through this. The `isNull` branch is what makes `{ autoPromptATT: undefined }`
|
|
30
|
+
* fall back to [default] instead of silently meaning `false`.
|
|
31
|
+
*/
|
|
32
|
+
internal fun ReadableMap.optBoolean(key: String, default: Boolean): Boolean =
|
|
33
|
+
if (hasKey(key) && !isNull(key)) getBoolean(key) else default
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Marshal the attribution slice of the JS configure options into
|
|
37
|
+
* [Attribution.Configuration]. Used by BOTH `configure` and `configureCore` so
|
|
38
|
+
* the documented contract ("the options are carried through") holds on Android
|
|
39
|
+
* exactly as it does on iOS — before this existed the Kotlin bridge dropped
|
|
40
|
+
* `autoPromptATT` / `sendInstallOnFirstLaunch` on the floor and every RN app
|
|
41
|
+
* silently got the Kotlin defaults instead of the caller's values.
|
|
42
|
+
*
|
|
43
|
+
* Defaults deliberately mirror `ios/SwissKnifePurchases.swift`, NOT the Kotlin
|
|
44
|
+
* data class:
|
|
45
|
+
* - `autoPromptATT` → **false**. iOS never shows the ATT prompt unless the
|
|
46
|
+
* host opts in; the field is an inert iOS-parity flag on Android, but the
|
|
47
|
+
* value the two bridges hand the native layer must still agree.
|
|
48
|
+
* - `sendInstallOnFirstLaunch` → **true**. Registering an organic install
|
|
49
|
+
* needs no consent on either platform.
|
|
50
|
+
*
|
|
51
|
+
* [Attribution.Configuration.collectAdvertisingId] and
|
|
52
|
+
* [Attribution.Configuration.collectInstallReferrer] are deliberately NOT
|
|
53
|
+
* exposed over the bridge and keep their Kotlin defaults. They gate
|
|
54
|
+
* `advertisingIdCollector` / `installReferrerCollector`, both of which are
|
|
55
|
+
* `Noop*` implementations with no public production setter — so toggling them
|
|
56
|
+
* from JS could not change what any shipped app collects. Adding cross-platform
|
|
57
|
+
* options that provably do nothing is worse than omitting them. If real
|
|
58
|
+
* collectors ever land, expose them then and document them as Android-only
|
|
59
|
+
* (no-ops on iOS).
|
|
60
|
+
*/
|
|
61
|
+
internal fun attributionConfigurationFrom(options: ReadableMap): Attribution.Configuration =
|
|
62
|
+
Attribution.Configuration(
|
|
63
|
+
autoPromptATT = options.optBoolean("autoPromptATT", false),
|
|
64
|
+
sendInstallOnFirstLaunch = options.optBoolean("sendInstallOnFirstLaunch", true),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Map a typed [PurchasesErrorCode] to the numeric string code JS expects. The
|
|
69
|
+
* values match the `PURCHASES_ERROR_CODE` constants in `src/types.ts`, so the
|
|
70
|
+
* JS `PurchasesError` surface keeps working unchanged.
|
|
71
|
+
*/
|
|
72
|
+
internal fun errorCodeToString(code: PurchasesErrorCode): String = when (code) {
|
|
73
|
+
PurchasesErrorCode.UnknownError -> "0"
|
|
74
|
+
PurchasesErrorCode.PurchaseCancelledError -> "1"
|
|
75
|
+
PurchasesErrorCode.StoreProblemError -> "2"
|
|
76
|
+
PurchasesErrorCode.PurchaseNotAllowedError -> "3"
|
|
77
|
+
PurchasesErrorCode.PurchaseInvalidError -> "4"
|
|
78
|
+
PurchasesErrorCode.ProductNotAvailableForPurchaseError -> "5"
|
|
79
|
+
PurchasesErrorCode.ProductAlreadyPurchasedError -> "6"
|
|
80
|
+
PurchasesErrorCode.ReceiptAlreadyInUseError -> "7"
|
|
81
|
+
PurchasesErrorCode.InvalidReceiptError -> "8"
|
|
82
|
+
PurchasesErrorCode.MissingReceiptFileError -> "9"
|
|
83
|
+
PurchasesErrorCode.NetworkError -> "10"
|
|
84
|
+
PurchasesErrorCode.InvalidCredentialsError -> "11"
|
|
85
|
+
PurchasesErrorCode.UnexpectedBackendResponseError -> "12"
|
|
86
|
+
PurchasesErrorCode.ReceiptInUseByOtherSubscriberError -> "13"
|
|
87
|
+
PurchasesErrorCode.InvalidAppUserIdError -> "14"
|
|
88
|
+
PurchasesErrorCode.OperationAlreadyInProgressError -> "15"
|
|
89
|
+
PurchasesErrorCode.UnknownBackendError -> "16"
|
|
90
|
+
PurchasesErrorCode.InvalidAppleSubscriptionKeyError -> "17"
|
|
91
|
+
PurchasesErrorCode.IneligibleError -> "18"
|
|
92
|
+
PurchasesErrorCode.InsufficientPermissionsError -> "19"
|
|
93
|
+
PurchasesErrorCode.PaymentPendingError -> "20"
|
|
94
|
+
PurchasesErrorCode.InvalidSubscriberAttributesError -> "21"
|
|
95
|
+
PurchasesErrorCode.LogOutAnonymousUserError -> "22"
|
|
96
|
+
PurchasesErrorCode.ConfigurationError -> "23"
|
|
97
|
+
PurchasesErrorCode.UnsupportedError -> "24"
|
|
98
|
+
PurchasesErrorCode.EmptySubscriberAttributesError -> "25"
|
|
99
|
+
PurchasesErrorCode.CustomerInfoError -> "28"
|
|
100
|
+
}
|
|
@@ -42,7 +42,7 @@ class SwissKnifePurchasesModule(
|
|
|
42
42
|
}
|
|
43
43
|
val appUserID = if (options.hasKey("appUserID")) options.getString("appUserID") else null
|
|
44
44
|
val proxyURL = if (options.hasKey("proxyURL")) options.getString("proxyURL") else null
|
|
45
|
-
val useAmazon = options.
|
|
45
|
+
val useAmazon = options.optBoolean("useAmazon", false)
|
|
46
46
|
val logLevel = if (options.hasKey("logLevel")) options.getString("logLevel") else null
|
|
47
47
|
|
|
48
48
|
SwissKnife.configure(
|
|
@@ -52,6 +52,7 @@ class SwissKnifePurchasesModule(
|
|
|
52
52
|
proxyURL = proxyURL,
|
|
53
53
|
useAmazon = useAmazon,
|
|
54
54
|
logLevel = logLevel,
|
|
55
|
+
attribution = attributionConfigurationFrom(options),
|
|
55
56
|
)
|
|
56
57
|
|
|
57
58
|
// Bridge the native SDK's CustomerInfo stream to the JS event channel.
|
|
@@ -64,11 +65,46 @@ class SwissKnifePurchasesModule(
|
|
|
64
65
|
promise.resolve(null)
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Configure everything EXCEPT the store. Instantiates NO `BillingClient` and
|
|
70
|
+
* registers no `PurchasesUpdatedListener`, so an app whose purchases are
|
|
71
|
+
* owned by another library (RevenueCat, a hand-rolled BillingClient) can
|
|
72
|
+
* adopt identity / attribution / analytics without Play Billing contention.
|
|
73
|
+
* Also registers no install. Kept in lockstep with the iOS bridge method of
|
|
74
|
+
* the same name.
|
|
75
|
+
*/
|
|
76
|
+
@ReactMethod
|
|
77
|
+
fun configureCore(options: ReadableMap, promise: Promise) {
|
|
78
|
+
val apiKey = options.getString("apiKey")
|
|
79
|
+
if (apiKey.isNullOrEmpty()) {
|
|
80
|
+
promise.reject("CONFIGURATION", "configureCore requires a non-empty apiKey")
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
val appUserID = if (options.hasKey("appUserID")) options.getString("appUserID") else null
|
|
84
|
+
val proxyURL = if (options.hasKey("proxyURL")) options.getString("proxyURL") else null
|
|
85
|
+
val logLevel = if (options.hasKey("logLevel")) options.getString("logLevel") else null
|
|
86
|
+
|
|
87
|
+
SwissKnife.configureCore(
|
|
88
|
+
context = reactContext,
|
|
89
|
+
apiKey = apiKey,
|
|
90
|
+
appUserID = appUserID,
|
|
91
|
+
proxyURL = proxyURL,
|
|
92
|
+
logLevel = logLevel,
|
|
93
|
+
attribution = attributionConfigurationFrom(options),
|
|
94
|
+
)
|
|
95
|
+
promise.resolve(null)
|
|
96
|
+
}
|
|
97
|
+
|
|
67
98
|
@ReactMethod
|
|
68
99
|
fun isConfigured(promise: Promise) {
|
|
69
100
|
promise.resolve(SwissKnife.isConfigured)
|
|
70
101
|
}
|
|
71
102
|
|
|
103
|
+
@ReactMethod
|
|
104
|
+
fun isCoreConfigured(promise: Promise) {
|
|
105
|
+
promise.resolve(SwissKnife.isCoreConfigured)
|
|
106
|
+
}
|
|
107
|
+
|
|
72
108
|
// ----- CustomerInfo / Offerings -----
|
|
73
109
|
|
|
74
110
|
@ReactMethod
|
|
@@ -460,35 +496,6 @@ class SwissKnifePurchasesModule(
|
|
|
460
496
|
promise.reject(errorCodeToString(err.code), err.message, err)
|
|
461
497
|
}
|
|
462
498
|
|
|
463
|
-
internal fun errorCodeToString(code: PurchasesErrorCode): String = when (code) {
|
|
464
|
-
PurchasesErrorCode.UnknownError -> "0"
|
|
465
|
-
PurchasesErrorCode.PurchaseCancelledError -> "1"
|
|
466
|
-
PurchasesErrorCode.StoreProblemError -> "2"
|
|
467
|
-
PurchasesErrorCode.PurchaseNotAllowedError -> "3"
|
|
468
|
-
PurchasesErrorCode.PurchaseInvalidError -> "4"
|
|
469
|
-
PurchasesErrorCode.ProductNotAvailableForPurchaseError -> "5"
|
|
470
|
-
PurchasesErrorCode.ProductAlreadyPurchasedError -> "6"
|
|
471
|
-
PurchasesErrorCode.ReceiptAlreadyInUseError -> "7"
|
|
472
|
-
PurchasesErrorCode.InvalidReceiptError -> "8"
|
|
473
|
-
PurchasesErrorCode.MissingReceiptFileError -> "9"
|
|
474
|
-
PurchasesErrorCode.NetworkError -> "10"
|
|
475
|
-
PurchasesErrorCode.InvalidCredentialsError -> "11"
|
|
476
|
-
PurchasesErrorCode.UnexpectedBackendResponseError -> "12"
|
|
477
|
-
PurchasesErrorCode.ReceiptInUseByOtherSubscriberError -> "13"
|
|
478
|
-
PurchasesErrorCode.InvalidAppUserIdError -> "14"
|
|
479
|
-
PurchasesErrorCode.OperationAlreadyInProgressError -> "15"
|
|
480
|
-
PurchasesErrorCode.UnknownBackendError -> "16"
|
|
481
|
-
PurchasesErrorCode.InvalidAppleSubscriptionKeyError -> "17"
|
|
482
|
-
PurchasesErrorCode.IneligibleError -> "18"
|
|
483
|
-
PurchasesErrorCode.InsufficientPermissionsError -> "19"
|
|
484
|
-
PurchasesErrorCode.PaymentPendingError -> "20"
|
|
485
|
-
PurchasesErrorCode.InvalidSubscriberAttributesError -> "21"
|
|
486
|
-
PurchasesErrorCode.LogOutAnonymousUserError -> "22"
|
|
487
|
-
PurchasesErrorCode.ConfigurationError -> "23"
|
|
488
|
-
PurchasesErrorCode.UnsupportedError -> "24"
|
|
489
|
-
PurchasesErrorCode.EmptySubscriberAttributesError -> "25"
|
|
490
|
-
PurchasesErrorCode.CustomerInfoError -> "28"
|
|
491
|
-
}
|
|
492
499
|
}
|
|
493
500
|
|
|
494
501
|
/**
|