@livx.cc/native-kit 0.31.1 → 0.32.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livx.cc/native-kit",
3
- "version": "0.31.1",
3
+ "version": "0.32.1",
4
4
  "description": "Isomorphic native-capabilities kit for PWAs \u2014 same API in browser and in an appwrap native shell. Zero dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "Elya Livshitz",
@@ -117,6 +117,27 @@ export class BillingModule {
117
117
  return this.kit.invoke('billing.manageSubscriptions');
118
118
  }
119
119
 
120
+ /**
121
+ * iOS 15+ native-only: present StoreKit 2's **in-app** subscription-management sheet
122
+ * (`AppStore.showManageSubscriptions(in:)`). Unlike {@link manageSubscriptions} (which deep-links
123
+ * out to the App Store account page, StoreKit 1), this stays inside the app AND shows sandbox /
124
+ * TestFlight subscriptions — so it's the path to verify/cancel a sub during testing. Opt-in: the
125
+ * default `manageSubscriptions()` deep-link is unchanged; call this explicitly to use the sheet.
126
+ *
127
+ * Throws `UNSUPPORTED` on the web or Android (no StoreKit), and `NATIVE_ERROR` on iOS <15 / no
128
+ * presentable scene / a StoreKit error. Resolves once the user dismisses the sheet.
129
+ */
130
+ async showManageSubscriptionsSheet(): Promise<void> {
131
+ await this.kit.ready();
132
+ if (this.capability !== 'native') {
133
+ throw new KitError('UNSUPPORTED', 'The in-app subscriptions sheet is iOS-only (StoreKit 2). Use manageSubscriptions() on web/Android.');
134
+ }
135
+ // The sheet resolves only when the USER dismisses it (seconds to minutes), so the default 10s
136
+ // invoke timeout would fire mid-sheet and make the caller think it failed → a spurious fallback.
137
+ // Give it a long window; a dismissed-but-unreported sheet just leaves the promise pending (harmless).
138
+ return this.kit.invoke('billing.manageSubscriptionsSheet', undefined, { timeoutMs: 600_000 });
139
+ }
140
+
120
141
  /** Out-of-band transactions (renewals, Ask-to-Buy, cross-device). Native streams only. */
121
142
  onTransaction(cb: (receipt: PurchaseReceipt) => void): Unsubscribe {
122
143
  return this.kit.on('billing.transaction', (p) => cb(p as PurchaseReceipt));