@app-swiss-knife/react-native-sdk 0.4.0 → 0.5.1

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 (185) hide show
  1. package/CHANGELOG.md +473 -2
  2. package/LICENSE +21 -0
  3. package/README.md +279 -47
  4. package/SwissKnifePurchases.podspec +1 -1
  5. package/android/build.gradle +24 -2
  6. package/android/consumer-rules.pro +12 -0
  7. package/android/src/main/AndroidManifest.xml +15 -1
  8. package/android/src/main/java/com/swissknife/crashreporting/SKCrashReportingModule.kt +5 -4
  9. package/android/src/main/java/com/swissknife/purchases/SwissKnifeJson.kt +20 -2
  10. package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +168 -6
  11. package/android/src/play/java/com/swissknife/purchases/StoreIntentHandler.kt +7 -0
  12. package/android/src/rustore/java/com/swissknife/purchases/StoreIntentHandler.kt +9 -0
  13. package/android/vendor/GENERATED.md +1 -0
  14. package/android/vendor/java/com/appswissknife/SwissKnife.kt +111 -38
  15. package/android/vendor/java/com/appswissknife/analytics/SKAnalytics.kt +180 -115
  16. package/android/vendor/java/com/appswissknife/attributes/AttributesClient.kt +16 -18
  17. package/android/vendor/java/com/appswissknife/attributes/SetAttributesWorker.kt +13 -13
  18. package/android/vendor/java/com/appswissknife/attribution/Attribution.kt +56 -25
  19. package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +1 -1
  20. package/android/vendor/java/com/appswissknife/crashreporting/SKCrashReporting.kt +365 -206
  21. package/android/vendor/java/com/appswissknife/entitlements/EntitlementsRepository.kt +195 -26
  22. package/android/vendor/java/com/appswissknife/identity/Identity.kt +31 -6
  23. package/android/vendor/java/com/appswissknife/models/PurchasesError.kt +5 -0
  24. package/android/vendor/java/com/appswissknife/net/BackendHttpClient.kt +56 -31
  25. package/android/vendor/java/com/appswissknife/net/IngestClient.kt +673 -87
  26. package/android/vendor/java/com/appswissknife/net/OfflineQueueStore.kt +214 -30
  27. package/android/vendor/java/com/appswissknife/notifications/NotificationRenderer.kt +195 -0
  28. package/android/vendor/java/com/appswissknife/notifications/PermissionRequestActivity.kt +60 -0
  29. package/android/vendor/java/com/appswissknife/notifications/PermissionStatus.kt +41 -0
  30. package/android/vendor/java/com/appswissknife/notifications/PushEventQueue.kt +143 -0
  31. package/android/vendor/java/com/appswissknife/notifications/PushPayload.kt +72 -0
  32. package/android/vendor/java/com/appswissknife/notifications/PushRegistration.kt +89 -0
  33. package/android/vendor/java/com/appswissknife/notifications/SwissKnifeMessagingService.kt +57 -0
  34. package/android/vendor/java/com/appswissknife/notifications/SwissKnifeNotifications.kt +438 -0
  35. package/android/vendor/java/com/appswissknife/offerings/OfferingsRepository.kt +312 -65
  36. package/android/vendor/java/com/appswissknife/performance/SKPerformance.kt +1 -0
  37. package/android/vendor/java/com/appswissknife/purchases/BillingClientGateway.kt +705 -96
  38. package/android/vendor/java/com/appswissknife/purchases/PlayPriceEnrichmentProvider.kt +55 -24
  39. package/android/vendor/java/com/appswissknife/purchases/ProductKindHint.kt +29 -0
  40. package/android/vendor/java/com/appswissknife/purchases/PurchasesGateway.kt +24 -0
  41. package/android/vendor-rustore/AndroidManifest.xml +59 -0
  42. package/android/vendor-rustore/java/com/appswissknife/rustore/RuStoreGateway.kt +428 -0
  43. package/android/vendor-rustore/java/com/appswissknife/rustore/RuStoreInitProvider.kt +43 -0
  44. package/android/vendor-rustore/java/com/appswissknife/rustore/RuStorePriceEnrichmentProvider.kt +85 -0
  45. package/app.plugin.js +343 -0
  46. package/ios/SwissKnifeJSON.swift +24 -2
  47. package/ios/SwissKnifePurchases.m +20 -0
  48. package/ios/SwissKnifePurchases.swift +97 -3
  49. package/ios/SwissKnifePushBootstrap.m +34 -0
  50. package/ios/vendor/GENERATED.md +1 -0
  51. package/ios/vendor/SwissKnifeiOS/Analytics/SKAnalytics.swift +138 -89
  52. package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +1 -1
  53. package/ios/vendor/SwissKnifeiOS/CrashReporting/SKCrashReporting.swift +345 -44
  54. package/ios/vendor/SwissKnifeiOS/Net/BackendBackoffGate.swift +43 -2
  55. package/ios/vendor/SwissKnifeiOS/Net/IngestClient.swift +495 -16
  56. package/ios/vendor/SwissKnifeiOS/Net/OfflineQueueStore.swift +231 -23
  57. package/ios/vendor/SwissKnifeiOS/Notifications/PushPayload.swift +87 -0
  58. package/ios/vendor/SwissKnifeiOS/Notifications/PushRegistrar.swift +322 -0
  59. package/ios/vendor/SwissKnifeiOS/Notifications/SwissKnife+Notifications.swift +403 -0
  60. package/ios/vendor/SwissKnifeiOS/Performance/SKPerformance.swift +1 -0
  61. package/ios/vendor/SwissKnifeiOS/Services/EntitlementsService.swift +11 -7
  62. package/ios/vendor/SwissKnifeiOS/Services/OfferingsService.swift +37 -5
  63. package/ios/vendor/SwissKnifeiOS/Services/PurchaseService.swift +38 -7
  64. package/ios/vendor/SwissKnifeiOS/SwissKnife.swift +34 -6
  65. package/ios/vendor/SwissKnifeiOS/Types.swift +31 -1
  66. package/ios-notification-service/SwissKnifeNotificationService.podspec +37 -0
  67. package/ios-notification-service/vendor/GENERATED.md +11 -0
  68. package/ios-notification-service/vendor/SwissKnifeNotificationService/SwissKnifeNotificationServiceExtension.swift +177 -0
  69. package/lib/commonjs/attribution.js +4 -3
  70. package/lib/commonjs/attribution.js.map +1 -1
  71. package/lib/commonjs/identity.js +12 -11
  72. package/lib/commonjs/identity.js.map +1 -1
  73. package/lib/commonjs/index.js +16 -5
  74. package/lib/commonjs/index.js.map +1 -1
  75. package/lib/commonjs/internal/config.js +105 -8
  76. package/lib/commonjs/internal/config.js.map +1 -1
  77. package/lib/commonjs/internal/telemetry-context.js +70 -0
  78. package/lib/commonjs/internal/telemetry-context.js.map +1 -0
  79. package/lib/commonjs/modules/analytics.js +18 -25
  80. package/lib/commonjs/modules/analytics.js.map +1 -1
  81. package/lib/commonjs/modules/crash-reporting.js +27 -6
  82. package/lib/commonjs/modules/crash-reporting.js.map +1 -1
  83. package/lib/commonjs/modules/log.js +1 -1
  84. package/lib/commonjs/modules/notifications.js +500 -0
  85. package/lib/commonjs/modules/notifications.js.map +1 -0
  86. package/lib/commonjs/modules/performance.js +57 -8
  87. package/lib/commonjs/modules/performance.js.map +1 -1
  88. package/lib/commonjs/native/module.js +6 -0
  89. package/lib/commonjs/native/module.js.map +1 -1
  90. package/lib/commonjs/native/spec.js +12 -5
  91. package/lib/commonjs/native/spec.js.map +1 -1
  92. package/lib/commonjs/purchases.js +4 -4
  93. package/lib/commonjs/types.js +12 -15
  94. package/lib/commonjs/types.js.map +1 -1
  95. package/lib/module/attribution.js +4 -3
  96. package/lib/module/attribution.js.map +1 -1
  97. package/lib/module/identity.js +12 -11
  98. package/lib/module/identity.js.map +1 -1
  99. package/lib/module/index.js +8 -4
  100. package/lib/module/index.js.map +1 -1
  101. package/lib/module/internal/config.js +103 -8
  102. package/lib/module/internal/config.js.map +1 -1
  103. package/lib/module/internal/telemetry-context.js +63 -0
  104. package/lib/module/internal/telemetry-context.js.map +1 -0
  105. package/lib/module/modules/analytics.js +18 -25
  106. package/lib/module/modules/analytics.js.map +1 -1
  107. package/lib/module/modules/crash-reporting.js +27 -6
  108. package/lib/module/modules/crash-reporting.js.map +1 -1
  109. package/lib/module/modules/log.js +1 -1
  110. package/lib/module/modules/notifications.js +491 -0
  111. package/lib/module/modules/notifications.js.map +1 -0
  112. package/lib/module/modules/performance.js +57 -8
  113. package/lib/module/modules/performance.js.map +1 -1
  114. package/lib/module/native/module.js +6 -1
  115. package/lib/module/native/module.js.map +1 -1
  116. package/lib/module/native/spec.js +11 -4
  117. package/lib/module/native/spec.js.map +1 -1
  118. package/lib/module/purchases.js +4 -4
  119. package/lib/module/types.js +12 -15
  120. package/lib/module/types.js.map +1 -1
  121. package/lib/typescript/commonjs/attribution.d.ts +3 -2
  122. package/lib/typescript/commonjs/attribution.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/identity.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/index.d.ts +2 -0
  125. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/internal/config.d.ts +16 -2
  127. package/lib/typescript/commonjs/internal/config.d.ts.map +1 -1
  128. package/lib/typescript/commonjs/internal/telemetry-context.d.ts +22 -0
  129. package/lib/typescript/commonjs/internal/telemetry-context.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/modules/analytics.d.ts +8 -11
  131. package/lib/typescript/commonjs/modules/analytics.d.ts.map +1 -1
  132. package/lib/typescript/commonjs/modules/crash-reporting.d.ts +18 -5
  133. package/lib/typescript/commonjs/modules/crash-reporting.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/modules/notifications.d.ts +110 -0
  135. package/lib/typescript/commonjs/modules/notifications.d.ts.map +1 -0
  136. package/lib/typescript/commonjs/modules/performance.d.ts +13 -0
  137. package/lib/typescript/commonjs/modules/performance.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/native/module.d.ts +2 -0
  139. package/lib/typescript/commonjs/native/module.d.ts.map +1 -1
  140. package/lib/typescript/commonjs/native/spec.d.ts +33 -4
  141. package/lib/typescript/commonjs/native/spec.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/purchases.d.ts +4 -4
  143. package/lib/typescript/commonjs/types.d.ts +4 -5
  144. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  145. package/lib/typescript/module/attribution.d.ts +3 -2
  146. package/lib/typescript/module/attribution.d.ts.map +1 -1
  147. package/lib/typescript/module/identity.d.ts.map +1 -1
  148. package/lib/typescript/module/index.d.ts +2 -0
  149. package/lib/typescript/module/index.d.ts.map +1 -1
  150. package/lib/typescript/module/internal/config.d.ts +16 -2
  151. package/lib/typescript/module/internal/config.d.ts.map +1 -1
  152. package/lib/typescript/module/internal/telemetry-context.d.ts +22 -0
  153. package/lib/typescript/module/internal/telemetry-context.d.ts.map +1 -0
  154. package/lib/typescript/module/modules/analytics.d.ts +8 -11
  155. package/lib/typescript/module/modules/analytics.d.ts.map +1 -1
  156. package/lib/typescript/module/modules/crash-reporting.d.ts +18 -5
  157. package/lib/typescript/module/modules/crash-reporting.d.ts.map +1 -1
  158. package/lib/typescript/module/modules/notifications.d.ts +110 -0
  159. package/lib/typescript/module/modules/notifications.d.ts.map +1 -0
  160. package/lib/typescript/module/modules/performance.d.ts +13 -0
  161. package/lib/typescript/module/modules/performance.d.ts.map +1 -1
  162. package/lib/typescript/module/native/module.d.ts +2 -0
  163. package/lib/typescript/module/native/module.d.ts.map +1 -1
  164. package/lib/typescript/module/native/spec.d.ts +33 -4
  165. package/lib/typescript/module/native/spec.d.ts.map +1 -1
  166. package/lib/typescript/module/purchases.d.ts +4 -4
  167. package/lib/typescript/module/types.d.ts +4 -5
  168. package/lib/typescript/module/types.d.ts.map +1 -1
  169. package/package.json +13 -4
  170. package/src/attribution.ts +4 -3
  171. package/src/identity.ts +12 -11
  172. package/src/index.ts +16 -4
  173. package/src/internal/config.ts +113 -8
  174. package/src/internal/telemetry-context.ts +76 -0
  175. package/src/modules/analytics.ts +24 -33
  176. package/src/modules/crash-reporting.ts +50 -9
  177. package/src/modules/log.ts +1 -1
  178. package/src/modules/notifications.ts +557 -0
  179. package/src/modules/performance.ts +94 -14
  180. package/src/native/module.ts +6 -0
  181. package/src/native/spec.ts +45 -10
  182. package/src/purchases.ts +4 -4
  183. package/src/types.ts +12 -15
  184. package/android/vendor/java/com/appswissknife/analytics/EventQueueStore.kt +0 -326
  185. package/android/vendor/java/com/appswissknife/analytics/FlushEventsWorker.kt +0 -296
package/CHANGELOG.md CHANGED
@@ -10,6 +10,453 @@ While the major version is `0`, a minor bump may carry behavioral changes that a
10
10
  The native iOS and Android SDKs are not published separately — their sources are
11
11
  vendored into this npm tarball at pack time, so a version here covers all three.
12
12
 
13
+ ## [Unreleased]
14
+
15
+ ## [0.5.1] - 2026-11-24
16
+
17
+ Google Play consumables can be bought again, both platforms report each
18
+ product's real type, the iOS Notification Service Extension pod ships in this
19
+ package, and one Expo config can build for Google Play and for RuStore. The
20
+ fixes are in native code, so they reach users only through a new store build.
21
+
22
+ ### Upgrading from 0.5.0
23
+
24
+ 1. **Bump the dependency, commit the lockfile, rebuild the native app.**
25
+ `npm install @app-swiss-knife/react-native-sdk@0.5.1`, commit
26
+ `package.json` and the lockfile, then `npx expo prebuild --clean` (or let
27
+ EAS Build run prebuild), or `cd ios && pod install` and a Gradle sync on
28
+ bare React Native. Ship it as a new store build: an over-the-air JS update
29
+ does not carry it.
30
+ 2. **iOS product labels are now real.** Before, every iOS product reached JS
31
+ as `productCategory: "SUBSCRIPTION"` and
32
+ `productType: "AUTO_RENEWABLE_SUBSCRIPTION"`. A lifetime unlock or a
33
+ consumable is now `NON_SUBSCRIPTION` with its own `productType`. If your
34
+ paywall filters on `productCategory === "SUBSCRIPTION"` and should keep
35
+ one-time products, filter on `productType` instead, or show every package.
36
+ 3. **Android (Play): consumables can be sold for repeat purchase.** Type the
37
+ product as a consumable in the dashboard. A consumable a user bought with
38
+ 0.5.0 stays owned until `restorePurchases()` runs, or until the app reads
39
+ offerings that name it a consumable (see **Fixed**).
40
+
41
+ ### Added
42
+
43
+ - The iOS Notification Service Extension pod is part of this package. In the
44
+ extension target of your Podfile:
45
+ `pod 'SwissKnifeNotificationService', :path => '../node_modules/@app-swiss-knife/react-native-sdk/ios-notification-service'`.
46
+ It compiles only the extension class (Foundation and UserNotifications), and
47
+ the app pod compiles the same files as in 0.5.0. This replaces the 0.5.0
48
+ note that the extension class was not part of the npm package. See README
49
+ "Rich notifications".
50
+ - Expo config plugin: `SWISS_KNIFE_ANDROID_STORE=play|rustore`, read at
51
+ prebuild, so one app config can produce a Google Play build and a RuStore
52
+ build (set it in each EAS build profile's `env`). Unset keeps the old
53
+ behaviour: RuStore when `android.rustore` is configured. `rustore` without a
54
+ complete `android.rustore`, or any other value, fails the prebuild with an
55
+ error naming the fields; the check runs when the config is read, so it fails
56
+ an iOS prebuild too.
57
+ - Native iOS: `StoreProduct.productType` (`StoreProductType`, with
58
+ `isSubscription`).
59
+ - Native Android: `ProductKindHint.productKind`, the server's product type for
60
+ a product, and `PurchasesGateway.onServerProductTypes(types)` (default
61
+ no-op), which receives the server's type for each of the store's products
62
+ that the offerings name.
63
+
64
+ ### Changed
65
+
66
+ - iOS: `productType` and `productCategory` report the product's StoreKit type:
67
+ `AUTO_RENEWABLE_SUBSCRIPTION`, `NON_RENEWABLE_SUBSCRIPTION`, `CONSUMABLE` or
68
+ `NON_CONSUMABLE`, and `UNKNOWN` for a dashboard-only one-time product that
69
+ StoreKit did not return. `productCategory` is `SUBSCRIPTION` only for an
70
+ auto-renewable product; non-subscriptions have no `subscriptionPeriod`.
71
+ - Android: a one-time product is `CONSUMABLE` or `NON_CONSUMABLE` when the
72
+ server's catalogue names its type, `UNKNOWN` otherwise (it was always
73
+ `UNKNOWN`).
74
+ - The server's offerings name each product's type (`product_type`), except a
75
+ product with no duration whose type is still the dashboard's default
76
+ subscription type: that one is left out, so the SDKs keep treating it as a
77
+ one-time product.
78
+
79
+ ### Fixed
80
+
81
+ - Android (Play): consumables can be bought again. A one-time purchase is
82
+ consumed once the server's validation answer says its product is a
83
+ consumable (the server has recorded the purchase by then); every other
84
+ product is still only acknowledged. A failed consume is retried and never
85
+ fails the purchase. A consumable that 0.5.0 acknowledged and left owned is
86
+ consumed by `restorePurchases()`, and by the purchase check that runs after
87
+ `getOfferings()` reads offerings naming it a consumable; the same check runs
88
+ when Play answers `ITEM_ALREADY_OWNED`, so the next attempt can buy.
89
+ - Expo config plugin: `android.rustore` no longer turns every Android build
90
+ into a RuStore build when `SWISS_KNIFE_ANDROID_STORE=play` is set.
91
+ - The dashboard's native Android install snippet showed version 0.4.0; it now
92
+ follows the SDK version.
93
+
94
+ ### Known limitations
95
+
96
+ - Android: Play has no non-renewing subscriptions, so a product the server
97
+ types `non_renewing` is reported as `AUTO_RENEWABLE_SUBSCRIPTION`; iOS
98
+ reports `NON_RENEWABLE_SUBSCRIPTION`.
99
+ - Android (Play): a consumable bought before sign-in with 0.5.0 and validated
100
+ again under the signed-in user is refused by the server as another user's
101
+ purchase, so it stays owned, as in 0.5.0.
102
+
103
+ ## [0.5.0] - 2026-11-24
104
+
105
+ Push notifications, Android offerings and one-time products, Google Play
106
+ purchase reliability (pending payments, acknowledgements, reconnects), and
107
+ native telemetry that no longer stalls or drops a batch on a server refusal.
108
+ Several fixes live in the native iOS and Android code, so they reach users
109
+ only through a new store build. Some calls behave differently: read
110
+ **Upgrading from 0.4.x** before you ship.
111
+
112
+ ### Upgrading from 0.4.x
113
+
114
+ 1. **Bump the dependency and commit the lockfile.**
115
+ `npm install @app-swiss-knife/react-native-sdk@0.5.0` (or `yarn add` /
116
+ `pnpm add` with the same version), then commit `package.json` and the
117
+ lockfile so local, CI and EAS builds all resolve 0.5.0. `npx expo install`
118
+ works too, but this version ships an Expo config plugin, so it also adds
119
+ the package to `plugins` in `app.json` (or, with an `app.config.js`, asks
120
+ you to). The plugin sets the app up for push: the `aps-environment`
121
+ entitlement on iOS, which fails signing with a provisioning profile that
122
+ lacks the Push Notifications capability, and Firebase Cloud Messaging on
123
+ Android. Keep the plugin entry only if you use Swiss Knife push or RuStore
124
+ billing.
125
+ 2. **Rebuild the native app.** Expo: `npx expo prebuild --clean` (or let EAS
126
+ Build run prebuild), then build. Bare React Native: `cd ios && pod install`,
127
+ and a Gradle sync or clean build on Android. Ship 0.5.0 as a new store
128
+ build: an over-the-air JS update on top of a 0.4.x binary does not carry the
129
+ native fixes, and the JS and native halves must come from the same version.
130
+ 3. **Handle the behaviour changes** (details under **Changed**):
131
+ - `configure()` and `configureCore()` throw synchronously when `apiKey` is
132
+ empty or whitespace. Make sure every build profile, release included,
133
+ provides the key. `CrashReporting.init` with an empty key now logs an
134
+ error and stays off (0.4.x installed its handlers anyway and, on Android,
135
+ could keep the real key from reaching native delivery).
136
+ - iOS: `restorePurchases()` can show an Apple ID sign-in sheet. Call it only
137
+ from a "Restore purchases" button. To read the current state at launch,
138
+ use `getCustomerInfo()`.
139
+ - Android (Play): a pending payment (cash, deferred payment) rejects the
140
+ purchase with `PAYMENT_PENDING_ERROR` instead of resolving. Show "payment
141
+ pending" rather than an error or a cancellation. Once the payment clears,
142
+ Play delivers the purchase again (or the next launch finds it), and the
143
+ SDK validates it, re-reads the entitlements and sends the new
144
+ CustomerInfo to `addCustomerInfoUpdateListener` listeners. Listen there to
145
+ unlock the content; no restore is needed.
146
+ - Android: `getCustomerInfo()` reads the entitlements from the server. With
147
+ nothing cached and the server unreachable or answering with an error, it
148
+ rejects with `NETWORK_ERROR`, as on iOS, instead of resolving with no
149
+ entitlements. Treat that as "unknown", not as "not subscribed".
150
+ - Android (Play): the SDK acknowledges one-time products and never consumes
151
+ them, so Play keeps a consumable owned: it can be bought once, and buying
152
+ it again rejects with `RECEIPT_ALREADY_IN_USE_ERROR`. Do not sell a
153
+ consumable for repeat purchase on Android yet.
154
+ - Android (Play): any HTTP error answer to purchase validation, 429 and 5xx
155
+ included, rejects with `UNEXPECTED_BACKEND_RESPONSE_ERROR` instead of
156
+ `NETWORK_ERROR`; `NETWORK_ERROR` now means no answer reached the device.
157
+ The JS error has no HTTP status field. If your app treated `NETWORK_ERROR`
158
+ as "try again later" to ride out a server outage, treat this code the same
159
+ way: the purchase stays unacknowledged, the SDK validates it again on the
160
+ next billing connection (the next launch at the latest), and
161
+ `restorePurchases()` validates subscriptions and one-time products again.
162
+ - Android: the module's manifest declares
163
+ `android.permission.POST_NOTIFICATIONS` and a transparent
164
+ `PermissionRequestActivity`, so both merge into your app. The permission
165
+ prompt appears only when you call `Notifications.requestPermission()`. An
166
+ app that must not declare the permission can remove it in its own manifest
167
+ with `tools:node="remove"`.
168
+ - Push needs no change unless you adopt it or add the config plugin (README
169
+ "Push notifications"). iOS asks for an APNs token only after
170
+ `Notifications.requestPermission()` or
171
+ `Notifications.registerForPushNotifications()`. On Android, an app that
172
+ already ships Firebase Cloud Messaging (for example through
173
+ `@react-native-firebase/messaging` or `expo-notifications`) and holds the
174
+ notification permission has its FCM token registered with Swiss Knife when
175
+ the SDK starts (`configure`, `configureCore`, `Analytics.init` or
176
+ `CrashReporting.init`), so the device shows up in the push audience; the
177
+ SDK does not handle incoming messages unless its
178
+ `SwissKnifeMessagingService` is declared. The iOS SDK now contains APNs
179
+ registration code, so App Store Connect may warn about a missing push
180
+ entitlement on upload for an app without push; the warning does not
181
+ block the build.
182
+ - Native Android apps (not React Native) that use `SKAnalytics` or
183
+ `SKCrashReporting` must call `SwissKnife.configureCore` (or `configure`):
184
+ events and crash reports are held until then. An app that opts out of
185
+ analytics or turns session events off calls `SKAnalytics.initialize`
186
+ before `configureCore`. React Native apps need no change here.
187
+ - `Attributes.setPushToken` only sets the `$pushToken` attribute; it does
188
+ not register the device for delivery (the native `SwissKnife.setPushToken`
189
+ is deprecated for that reason). Register a device with
190
+ `Notifications.registerDeviceToken` or
191
+ `Notifications.registerForPushNotifications()`.
192
+
193
+ No peer dependency changed (`react >= 18`, `react-native >= 0.73`, optional
194
+ `@react-native-async-storage/async-storage`), the iOS pod still targets iOS
195
+ 15.1, and the Android module's defaults (minSdk 24, compileSdk 35) are
196
+ unchanged.
197
+
198
+ ### Added
199
+
200
+ - Push notifications: a `Notifications` module with a native mode (the SDK owns
201
+ the APNs/FCM token) and a manual mode (`expo-notifications` or React Native
202
+ Firebase hand over the token and payloads), the native iOS
203
+ `SwissKnife.Notifications` and Android `SwissKnife.notifications` APIs, the
204
+ Android `SwissKnifeMessagingService`, and an Expo config plugin
205
+ (`app.plugin.js`). `firebase-messaging` is a compile-only dependency, so an
206
+ app that does not use push does not pull in Firebase. The iOS
207
+ `SwissKnifeNotificationService` extension base class for rich notifications
208
+ belongs to the native Swift package and is not part of this npm package. See
209
+ README "Push notifications".
210
+ - Performance: `Performance.init({ trackAppStart: true })` records the cold
211
+ start as an `app.start` transaction, from when the SDK module loaded to your
212
+ call of `Performance.finishAppStart()`. Off by default; sampling applies.
213
+ - Performance: a `buildNumber` option. Transactions carry their span id and the
214
+ session, user and install ids, and JS crash events carry the session id and
215
+ the trace id of the transaction active when they were captured, so a trace
216
+ links to the session's events and errors.
217
+ - Android: optional RuStore billing. The Expo plugin option
218
+ `android: { rustore: { consoleAppId, scheme } }` sets the Gradle property
219
+ `swissKnifeStore=rustore`, adds RuStore's manifest metadata and the payment
220
+ return deeplink, and makes the launcher Activity `singleTask`. Without it,
221
+ builds use Google Play and load no RuStore dependency. The option is part of
222
+ the push config plugin, so adding the plugin also applies its push setup
223
+ (the `aps-environment` entitlement and the `remote-notification` background
224
+ mode on iOS; `firebase-messaging`, `POST_NOTIFICATIONS` and, unless
225
+ `expo-notifications` or `@react-native-firebase/messaging` is in the
226
+ project, `SwissKnifeMessagingService` on Android). A RuStore purchase made
227
+ before login is kept under the persisted anonymous id, so it is still found
228
+ after a restart and merges into the account on identify, and its validation
229
+ retries 5xx, 429 and transport failures. See README "Optional RuStore
230
+ billing (Android)".
231
+ - Android (native): `Attribution.setCollectors(advertisingId, installReferrer)`.
232
+ The SDK still ships no advertising-id or install-referrer collector and adds no
233
+ Play dependency; a host that has them passes its own, and their values reach the
234
+ install POST. The docs no longer mention a `setProductionCollectors` that never
235
+ existed.
236
+ - Android (native): `PurchasesError.httpStatus`, `.backendErrorCode` and
237
+ `.requestId` expose the server's validation diagnostics when it refused a
238
+ purchase. Raw response bodies, purchase tokens and receipts are never
239
+ included.
240
+
241
+ ### Changed
242
+
243
+ - `configure()` / `configureCore()` throw synchronously when `apiKey` is empty or
244
+ whitespace. They used to mark the SDK configured and fail on the first store
245
+ call, so an app built with a missing key now throws at startup.
246
+ - Android (Play): a PENDING purchase (cash, deferred payment) rejects with
247
+ `PAYMENT_PENDING_ERROR` instead of resolving. It is never validated or
248
+ acknowledged while pending; Play delivers it again once it is paid, and the SDK
249
+ validates it then.
250
+ - Android (Play): every billing connection (configure and each reconnect)
251
+ validates and acknowledges the SUBS and INAPP purchases that are PURCHASED but
252
+ still unacknowledged, consumables included. A purchase stamped with a signed-in
253
+ user id at launch is validated under that user, any other under the current
254
+ subject.
255
+ - Android (Play): a purchase or restore made while the billing client is
256
+ disconnected waits up to 15 s for a reconnect. A failed reconnect rejects with
257
+ the mapped Play error (for example `PURCHASE_NOT_ALLOWED_ERROR`) instead of
258
+ `STORE_PROBLEM_ERROR`.
259
+ - iOS: `restorePurchases()` calls `AppStore.sync()` first, which can show an
260
+ Apple ID sign-in sheet. Call it from a user action, never silently at launch.
261
+ - iOS: a restore, a `Transaction.updates` delivery or a silent push no longer
262
+ clears the cached entitlements before refreshing. A failed refresh keeps what
263
+ the user had, so a refund or revocation shows only once a refresh succeeds or
264
+ the 24 h cache expires.
265
+ - Android (native): `SKAnalytics` and `SKCrashReporting` deliver only through
266
+ `/ingest`, which `SwissKnife.configureCore` / `configure` wire. Events and
267
+ reports from before that call are held in memory (the newest 1,000 analytics
268
+ events, 100 captured errors and 100 other reports). They are sent within a
269
+ second of that call when it comes in the first five minutes, otherwise with
270
+ the next delivery or the 30 s flush; crash files from earlier launches wait
271
+ on disk (the newest 10, none overwritten) and exit records in the OS. The
272
+ legacy queue (`EventQueueStore`, `FlushEventsWorker`, `/api/sdk/events/batch`,
273
+ the direct `/api/sdk/errors/*` posts, `pending-queue.json`) is removed: its
274
+ leftover files are deleted and its WorkManager job is cancelled on upgrade. A
275
+ native app that calls `SKAnalytics.initialize` or `SKCrashReporting.init`
276
+ without `configureCore` sends nothing until it adds that call. `configureCore`
277
+ keeps the configuration of an `SKAnalytics` the app already initialized; when
278
+ analytics is not initialized yet, it initializes it with the defaults, which
279
+ tracks a Session Start. An app that opts out or turns session events off
280
+ calls `SKAnalytics.initialize` first. The React Native bridge already wires
281
+ `/ingest` first, so React Native apps are unaffected.
282
+ - Android (Play): a purchase whose validation gets an HTTP error answer (any
283
+ non-2xx status, 429 and 5xx included) rejects with
284
+ `UNEXPECTED_BACKEND_RESPONSE_ERROR` and an SDK-owned message instead of
285
+ `NETWORK_ERROR`; only a transport failure (no answer) stays `NETWORK_ERROR`.
286
+ Validation is not retried within the call: the purchase stays
287
+ unacknowledged and is validated again on the next billing connection. A
288
+ restore whose validation fails rejects with the code of the first failure
289
+ instead of a generic `NETWORK_ERROR`. Purchases are sent for validation as one
290
+ `packageName:productId:purchaseToken` receipt (`platform: "android"`), the
291
+ shape the server validates for subscriptions and one-time products alike; the
292
+ server still accepts the request 0.4.x sends.
293
+ - Android: `getCustomerInfo()` with nothing cached rejects with
294
+ `NETWORK_ERROR` when the server cannot be reached or answers with an error
295
+ (a 429 or 5xx included), as on iOS; it used to resolve with no entitlements.
296
+ With a cache it still answers from the cache, even one older than 24 hours.
297
+ `logIn()` still resolves when the entitlement read fails, with no
298
+ entitlements, as before.
299
+ - Android (Play): `restorePurchases()` rejects when Play fails to list either
300
+ the subscriptions or the one-time purchases, instead of resolving with a
301
+ partial restore.
302
+ - Android: an offering's packages carry the package identifier and package
303
+ type set on the server, as on iOS, and `product.subscriptionPeriod` is filled
304
+ in for subscriptions (from Play, or from the dashboard duration when Play
305
+ cannot price the product); it is null for one-time products.
306
+ - Android: the React Native module's manifest declares
307
+ `android.permission.POST_NOTIFICATIONS` and the transparent
308
+ `PermissionRequestActivity` that `Notifications.requestPermission()` launches,
309
+ so both are merged into every app. The prompt is shown only when the app asks.
310
+ - iOS (native): a telemetry batch the ingest server refuses with a 4xx no
311
+ longer blocks the queue for good. 401/403 keep the events and retry after 5
312
+ minutes; any other 4xx on several events (413, 400, 404 ...) splits the batch
313
+ to find the event at fault, so a batch is never dropped whole. An event
314
+ refused on its own is dropped to the dead-letter file only when the server
315
+ accepted another batch just before, one drop per accepted batch. Otherwise it
316
+ is set aside: kept, skipped so the events behind it go out, and offered again
317
+ once the server accepts something. The set-aside list and the pause of up to
318
+ 5 minutes after a drain the server refused are kept in a new file,
319
+ `set-aside.json`, beside the queue (`Library/Caches/SwissKnife/ingest/`), so
320
+ a relaunch neither starts over nor re-sends to a server refusing the queue; a
321
+ pause read back that ends more than 5 minutes ahead (a device clock set back)
322
+ is ignored. Android also keeps events on 401/403 now.
323
+ - Android (native): the same 4xx policy as iOS. A telemetry batch the ingest
324
+ server refuses is no longer dead-lettered whole: 408/425 keep the events and
325
+ back off like a 5xx, any other 4xx on several events splits the batch, and an
326
+ event refused on its own is dropped only when the server accepted another
327
+ batch just before (otherwise set aside and offered again), with the
328
+ set-aside list and the pause kept in `set-aside.json` beside the queue
329
+ (`cache/swissknife/ingest/`). A server refusing every batch is retried while
330
+ the app runs, not by background wake-ups.
331
+ - iOS and Android (native): the offline event queues no longer read their file
332
+ on every append, and the dead-letter files are capped (1 MB).
333
+ - Android (native): crash reports and breadcrumbs carry UTC timestamps from a
334
+ per-thread formatter; the crash handler installs once and always hands the
335
+ crash on to the previous handler.
336
+ - iOS (native): the ANR watchdog reports one ANR per hang and pauses while the
337
+ app is in the background.
338
+ - The package description and keywords name what the SDK ships (subscriptions,
339
+ analytics, crash reporting, performance, push) instead of calling it a
340
+ subscriptions-only drop-in replacement for `react-native-purchases`. Source
341
+ comments describe what the code does; the history they used to narrate is
342
+ under "Earlier history" below.
343
+
344
+ ### Fixed
345
+
346
+ - Android: `getOfferings()` returns the app's offerings, as on iOS: every
347
+ active paywall as an offering, `current` set to the one the dashboard marks
348
+ current, and each Google Play (or RuStore) package priced by the store, with
349
+ the dashboard price when the store cannot price it. It used to reject on
350
+ every call, so `purchasePackage()` could not find a package either. Packages
351
+ for other platforms are left out. A call made while Play is still connecting
352
+ (right after `configure()`) waits up to 5 seconds for it. The answer is cached
353
+ for an hour, or for a minute when the store priced none of its products, so
354
+ the store's prices replace the dashboard's as soon as the store answers. No
355
+ paywall slug is needed; the native `getOfferingsForPaywall` stays for a host
356
+ that renders one paywall with its experiment variant.
357
+ - Android (Play): one-time products (lifetime unlocks, consumables) are priced,
358
+ bought and restored. Prices were looked up as subscriptions only, a purchase
359
+ asked Play for the product as a subscription only and failed with
360
+ `PRODUCT_NOT_AVAILABLE_FOR_PURCHASE_ERROR`, and `restorePurchases()` skipped
361
+ one-time purchases. A product is asked for as the type its package
362
+ describes; one bought by id alone (`purchaseStoreProduct`) is asked for as a
363
+ subscription first, then as a one-time product. Consumables are
364
+ acknowledged, not consumed, so a consumable can be bought once: a second
365
+ purchase rejects with `RECEIPT_ALREADY_IN_USE_ERROR`. A product the SDK
366
+ knows is one-time reaches JS with `productCategory: "NON_SUBSCRIPTION"` and
367
+ `productType: "UNKNOWN"` instead of being labelled a subscription (iOS still
368
+ labels every product a subscription).
369
+ - Android: CustomerInfo carries the user's entitlements. `getCustomerInfo()`,
370
+ `restorePurchases()`, `logIn()` and a purchase answered from a device cache
371
+ that nothing filled, so Android reported no entitlements, even right after a
372
+ purchase. They now read the user's whole entitlement set from the server, as
373
+ iOS does: every entitlement the app defines (active or not, with product,
374
+ store, period type and dates), the active subscriptions and the purchase
375
+ dates. A failed read keeps the cached entitlements. The cache belongs to the
376
+ user it was read for: after a `logIn()`, a `logOut()` or a launch configured
377
+ with another `appUserID`, the new user's entitlements are read rather than
378
+ the previous user's served, as on iOS, and a read that finishes after the
379
+ switch is not kept.
380
+ - Android: `Identity.reset()` and `Identity.wipe()` take purchases back to the
381
+ anonymous user, as on iOS. After a `logIn()`, the purchases layer kept the
382
+ user they left for the rest of the process: `getCustomerInfo()` served that
383
+ user's entitlements, and a purchase was validated under that user. They now
384
+ drop that user's id and cached entitlements (memory and disk) without
385
+ contacting the store or the server, and the next `getCustomerInfo()` reads
386
+ the anonymous user's entitlements. On Android, `addCustomerInfoUpdateListener`
387
+ listeners also receive the anonymous user's CustomerInfo, with no
388
+ entitlements (iOS sends no event). A `logOut()` after a reset or wipe
389
+ resolves, as on iOS.
390
+ - Android (Play): after a purchase is validated, the SDK re-reads the
391
+ entitlements, updates the cache and sends the new CustomerInfo to
392
+ `addCustomerInfoUpdateListener` listeners, as iOS does after a transaction
393
+ update. This covers a pending payment that clears later, a promo code or a
394
+ purchase made in the Play Store app, and a purchase the check on each billing
395
+ connection validated, not only the purchase in flight. A native listener
396
+ added before `configure` is notified too.
397
+ - iOS and Android (native): `SwissKnife.configure`, `configureCore` and
398
+ `configurePurchases` with an empty or whitespace `apiKey` log an error and
399
+ return without configuring anything. iOS trapped on a `precondition` (a crash
400
+ in release builds) and Android threw `IllegalArgumentException`, so a native
401
+ app built with a missing key crashed at launch. A later call with the real
402
+ key configures the SDK as usual.
403
+ - `CrashReporting.init` with an empty or whitespace `apiKey` logs an error and
404
+ does nothing: no handler is installed and the native crash module is not
405
+ started. On Android the empty key used to latch the native observability
406
+ wiring (`SwissKnife.ensureObservabilityBackend`), so in an app that calls
407
+ `Analytics.init` without `configure` the real key never reached the ingest
408
+ pipeline. `ensureObservabilityBackend` on Android and iOS now ignores an empty
409
+ or whitespace key without latching.
410
+ - Android (native): the install attribution POST sends `user_id` only for a
411
+ logged-in user, as iOS does. It used to send the anonymous id as `user_id`;
412
+ the server already treats that `$SKAnonymousID:` value as anonymous, so stored
413
+ data does not change.
414
+ - `configure()` / `configureCore()` no longer drop the native promise. A native
415
+ configure failure is logged (no unhandled rejection), resets the JS state so
416
+ the next `configure()` with the same key retries, and the next store call
417
+ throws `UninitializedPurchasesError` with the native error as `cause`.
418
+ `configure()` stays synchronous.
419
+ - Android (Play): acknowledgements are checked and retried (3 attempts with
420
+ backoff), and the reconcile on each billing connection picks up what is still
421
+ unacknowledged, so an ack lost to a network error or a process kill is no
422
+ longer auto-refunded by Google after three days. A purchase or restore after
423
+ the five reconnect attempts ran out reconnects instead of failing "Billing
424
+ client not ready" until the app restarts.
425
+ - iOS: a failed entitlement refresh after a restore, a transaction update or a
426
+ silent push no longer leaves the user with no entitlements.
427
+ - Android (native): `configure` / `configureCore` no longer re-initialize an
428
+ `SKAnalytics` the app already initialized. They used to replace its
429
+ configuration with the defaults, so a user who had opted out was tracked
430
+ again, session events came back on, the flush interval reset, and a second
431
+ Session Start was tracked. Analytics that was not initialized is still
432
+ initialized with the defaults. This applies to apps that call the native
433
+ `SKAnalytics.initialize`; a React Native app's JS `optOut` is not passed to
434
+ native, so its Android wiring is unchanged.
435
+ - Android (native): `SKAnalytics.identify` and `groupIdentify` send nothing
436
+ while opted out, as on iOS and in the JS layer. They used to send the user
437
+ or group properties anyway.
438
+ - The `enableNativeCrashHandler` docs said the iOS reporter catches Mach
439
+ exceptions. It never installed a Mach exception handler: it installs
440
+ `signal()` handlers (SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGTRAP), the
441
+ uncaught-NSException handler and an ANR watchdog, and the docs now say so.
442
+ - `CrashReporting.init` no longer passes an `ingestURL` to the native crash
443
+ module. It was not a `CrashReportingConfig` option and neither bridge read
444
+ it; native reports go to `serverURL`.
445
+ - iOS (native): the crash scope (tags, extra, user) and the breadcrumb buffer
446
+ are safe to change from any thread. An uncaught NSException raised on the
447
+ crash reporter's own queue (a `flush` completion, for example) is reported;
448
+ the handler used to dispatch synchronously onto the queue it was running on.
449
+
450
+ ### Deprecated
451
+
452
+ - Native `SwissKnife.setPushToken` only sets the `$pushToken` attribute; it does
453
+ not register the device for delivery. On iOS use
454
+ `SwissKnife.Notifications.registerDeviceToken(_:)`, on Android
455
+ `SwissKnife.notifications.registerToken`. The JS `Attributes.setPushToken`
456
+ (and its `Purchases.setPushToken` alias) also only sets the attribute but is
457
+ not deprecated; register a device from JS with
458
+ `Notifications.registerDeviceToken`.
459
+
13
460
  ## [0.4.0] - 2026-09-30
14
461
 
15
462
  Crash reporting release. No API is removed or renamed, and upgrading from 0.3.2
@@ -29,7 +476,7 @@ dashboard, so read **Changed** before you compare week-over-week numbers.
29
476
  handed to `configureScope()` could not be typed in user code; `captureException`'s
30
477
  options parameter is now a named type instead of an inline literal.
31
478
  - **Affected-user counts survive anonymous sessions.** When no user id is set, an
32
- install id is sent so an issue still reports how many *installs* it hit instead
479
+ install id is sent so an issue still reports how many _installs_ it hit instead
33
480
  of collapsing to zero. The id comes from the Identity bridge's `anonymousId`,
34
481
  falling back to a UUID persisted in AsyncStorage. With neither available nothing
35
482
  is sent — a per-launch random id would inflate the count, so we prefer no number
@@ -79,4 +526,28 @@ numbers to move once 0.4.0 rolls out; that is the fix working, not data loss.
79
526
  - No new or changed dependencies; peer ranges (`react`, `react-native`,
80
527
  `@react-native-async-storage/async-storage`) are untouched.
81
528
 
82
- [0.4.0]: https://github.com/Remneys/swiss-knife/releases/tag/react-native-sdk-v0.4.0
529
+ ## Earlier history
530
+
531
+ How the SDK reached its current shape before 0.4.0, as the source comments used
532
+ to narrate it:
533
+
534
+ - **RevenueCat removed.** The SDK began as a wrapper over RevenueCat's
535
+ `react-native-purchases` (`purchases-hybrid-common`). iOS moved to its own
536
+ StoreKit 2 services and Android to Play Billing directly, the RN bridge and
537
+ TypeScript types became this package's own (RevenueCat's names and field
538
+ shapes kept, `@revenuecat/purchases-typescript-internal` dropped), and the RN
539
+ analytics layer became a pass-through to the native event queue.
540
+ - **Identity.** One `Identity` namespace on iOS, Android and JS, with native as
541
+ the source of truth. Android started posting `/api/sdk/users/identify` on
542
+ login, analytics events read `user_id` from the native snapshot (an event
543
+ tracked right after login used to carry `user_id: ""`), and Android's
544
+ anonymous id moved from `$RCAnonymousID:` to `$SKAnonymousID:`.
545
+ - **Attribution.** One `Attribution` namespace; Android started posting the
546
+ install to `/api/sdk/attribution/install`.
547
+ - **Logging.** `setLogLevel` started filtering the SDK's own logs (`SKLog` on
548
+ iOS and Android, `modules/log.ts` in JS); it used to have no effect.
549
+ - **Session id.** Analytics' `session_id` became the native session UUID, the
550
+ same one on every ingested envelope, instead of a JS `Date.now()` value.
551
+
552
+ [0.5.0]: https://www.npmjs.com/package/@app-swiss-knife/react-native-sdk/v/0.5.0
553
+ [0.4.0]: https://www.npmjs.com/package/@app-swiss-knife/react-native-sdk/v/0.4.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 App Swiss Knife
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.