@rovenue/react-native-sdk 0.23.1 → 0.26.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.
@@ -65,6 +65,18 @@
65
65
  <array><string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string></array>
66
66
  </dict>
67
67
  </array>
68
+ <!--
69
+ Required-reason APIs the SDK's own code references (statically linked into
70
+ the app, so only this manifest can answer for them). Audited against every
71
+ shipped binary by e2e/live/privacy-manifest-audit.mjs.
72
+ FileTimestamp C617.1: stat/fstat/lstat in the bundled SQLite, Rust std and
73
+ tokio, on files in the app container (the cache database); the funnel
74
+ image disk cache reads and sets modification dates under Caches/.
75
+ DiskSpace E174.1: statfs/fstatfs in the bundled SQLite, which reads the
76
+ volume of the database file when opening it to decide how to write to it
77
+ (read-only mount, msdos/exfat, network file systems). Nothing derived
78
+ leaves the device.
79
+ -->
68
80
  <key>NSPrivacyAccessedAPITypes</key>
69
81
  <array>
70
82
  <dict>
@@ -72,6 +84,11 @@
72
84
  <key>NSPrivacyAccessedAPITypeReasons</key>
73
85
  <array><string>C617.1</string></array>
74
86
  </dict>
87
+ <dict>
88
+ <key>NSPrivacyAccessedAPIType</key><string>NSPrivacyAccessedAPICategoryDiskSpace</string>
89
+ <key>NSPrivacyAccessedAPITypeReasons</key>
90
+ <array><string>E174.1</string></array>
91
+ </dict>
75
92
  </array>
76
93
  </dict>
77
94
  </plist>
@@ -199,8 +199,10 @@ public class RovenueModule: Module {
199
199
  let u = await Rovenue.shared.currentUser()
200
200
  return ["rovenueId": u.rovenueId, "appUserId": u.appUserId as Any?]
201
201
  }
202
- AsyncFunction("identify") { (appUserId: String) in
203
- try await rovenueCall { try await Rovenue.shared.identify(appUserId) }
202
+ AsyncFunction("identify") { (appUserId: String, identityToken: String) in
203
+ try await rovenueCall {
204
+ try await Rovenue.shared.identify(appUserId: appUserId, identityToken: identityToken)
205
+ }
204
206
  }
205
207
  AsyncFunction("setAttribution") { (provider: String, data: [String: Any]) in
206
208
  guard let mmp = AttributionProvider(rawValue: provider) else {
@@ -289,6 +291,21 @@ public class RovenueModule: Module {
289
291
  throw RovenueCodedError(e)
290
292
  }
291
293
  }
294
+ AsyncFunction("preloadPlacement") { (placementId: String, locale: String?) in
295
+ guard #available(iOS 15.0, macOS 12.0, *) else { return }
296
+ await Rovenue.shared.preloadPlacement(placementId, locale: locale)
297
+ }
298
+ AsyncFunction("presentFunnel") { (presentationId: String, placement: String, locale: String?, styleJson: String?, callbacks: [String: Bool]) -> [String: Any?] in
299
+ guard #available(iOS 15.0, *) else {
300
+ return ["result": "unavailable", "purchased": false, "reason": FunnelPresentResult.noPresenter]
301
+ }
302
+ return await self.presentFunnel(
303
+ presentationId: presentationId, placement: placement, locale: locale,
304
+ styleJson: styleJson, callbacks: callbacks)
305
+ }
306
+ AsyncFunction("resolveFunnelPurchaseRequest") { (requestId: String, purchased: Bool) in
307
+ await FunnelPurchaseRequests.shared.resolve(requestId, purchased: purchased)
308
+ }
292
309
  AsyncFunction("purchase") { (productId: String, productType: String, promotionalOfferId: String?, basePlanId: String?, offerId: String?) -> [String: Any?] in
293
310
  // basePlanId/offerId select a Play subscription offer on Android; ignored on iOS.
294
311
  guard #available(iOS 15.0, macOS 12.0, *) else {
@@ -437,7 +454,7 @@ public class RovenueModule: Module {
437
454
  }
438
455
 
439
456
  // ---------------- Events ----------------
440
- Events("onChange", "onLog", "onFunnelClaimResolved")
457
+ Events("onChange", "onLog", "onFunnelClaimResolved", "onFunnelPresentEvent")
441
458
 
442
459
  OnStartObserving {
443
460
  self.changesTask = Task { [weak self] in
@@ -747,3 +764,94 @@ public class RovenueModule: Module {
747
764
  }
748
765
  }
749
766
  }
767
+
768
+ // MARK: - presentFunnel (spec 2026-11-03-funnel-presentation §2a)
769
+
770
+ /// Purchase / restore requests a presented funnel is waiting on, answered
771
+ /// from JS by `resolveFunnelPurchaseRequest`. Main-actor isolated: no lock.
772
+ @MainActor
773
+ final class FunnelPurchaseRequests {
774
+ static let shared = FunnelPurchaseRequests()
775
+ private var pending: [String: CheckedContinuation<Bool, Never>] = [:]
776
+ private var serial = 0
777
+
778
+ /// Emits a request through `send` and waits for JS's answer.
779
+ func ask(_ send: (String) -> Void) async -> Bool {
780
+ serial += 1
781
+ let requestId = "r\(serial)"
782
+ return await withCheckedContinuation { continuation in
783
+ pending[requestId] = continuation
784
+ send(requestId)
785
+ }
786
+ }
787
+
788
+ func resolve(_ requestId: String, purchased: Bool) {
789
+ pending.removeValue(forKey: requestId)?.resume(returning: purchased)
790
+ }
791
+ }
792
+
793
+ extension RovenueModule {
794
+ @available(iOS 15.0, *)
795
+ @MainActor
796
+ func presentFunnel(
797
+ presentationId: String, placement: String, locale: String?, styleJson: String?, callbacks: [String: Bool]
798
+ ) async -> [String: Any?] {
799
+ let emit: ([String: Any?]) -> Void = { [weak self] body in
800
+ var payload = body
801
+ payload["presentationId"] = presentationId
802
+ self?.sendEvent("onFunnelPresentEvent", payload as [String: Any])
803
+ }
804
+ var handlers = FunnelPresentHandlers()
805
+ if callbacks["onPurchase"] == true {
806
+ handlers.onPurchase = { packageId in
807
+ await FunnelPurchaseRequests.shared.ask { id in
808
+ emit(["type": "purchaseRequest", "requestId": id, "packageId": packageId])
809
+ }
810
+ }
811
+ }
812
+ if callbacks["onRestore"] == true {
813
+ handlers.onRestore = {
814
+ await FunnelPurchaseRequests.shared.ask { id in emit(["type": "restoreRequest", "requestId": id]) }
815
+ }
816
+ }
817
+ handlers.onPurchaseError = { error in emit(["type": "purchaseError", "error": Self.errorDTO(error)]) }
818
+ if callbacks["onUrl"] == true {
819
+ handlers.onUrl = { url in emit(["type": "url", "url": url]) }
820
+ }
821
+ if callbacks["onCustomAction"] == true {
822
+ handlers.onCustomAction = { id, params in emit(["type": "customAction", "actionId": id, "paramsJson": params]) }
823
+ }
824
+ let result = await Rovenue.shared.presentFunnel(
825
+ placement: placement, locale: locale, style: Self.presentationOverride(styleJson), handlers: handlers)
826
+ return [
827
+ "result": result.result.rawValue,
828
+ "purchased": result.purchased,
829
+ "customerInfo": result.customerInfo.map(Self.dtoFromPurchaseResult),
830
+ "lastError": result.lastError.map(Self.errorDTO),
831
+ "reason": result.reason,
832
+ ]
833
+ }
834
+
835
+ static func errorDTO(_ error: RovenueError) -> [String: Any?] {
836
+ [
837
+ "kind": String(describing: error.kind),
838
+ "message": error.message,
839
+ "serverCode": error.serverCode,
840
+ "httpStatus": error.httpStatus,
841
+ "retryable": error.isRetryable,
842
+ ]
843
+ }
844
+
845
+ /// The JS `style` object (a partial presentation, JSON).
846
+ static func presentationOverride(_ json: String?) -> FunnelPresentationOverride? {
847
+ guard let json, let data = json.data(using: .utf8),
848
+ let object = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any]
849
+ else { return nil }
850
+ return FunnelPresentationOverride(
851
+ style: (object["style"] as? String).flatMap(FunnelPresentationStyle.init(rawValue:)),
852
+ enter: (object["enter"] as? String).flatMap(FunnelPresentationEnter.init(rawValue:)),
853
+ detents: (object["detents"] as? [String])?.compactMap(FunnelSheetDetent.init(rawValue:)),
854
+ dismissible: object["dismissible"] as? Bool,
855
+ closeOnPurchase: object["closeOnPurchase"] as? Bool)
856
+ }
857
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rovenue/react-native-sdk",
3
- "version": "0.23.1",
3
+ "version": "0.26.0",
4
4
  "description": "Rovenue React Native SDK — subscriptions, entitlements, virtual currencies and funnels for Expo / React Native apps.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://rovenue.io",
@@ -1,7 +0,0 @@
1
- // src/version.ts
2
- var SDK_VERSION = "0.23.1";
3
-
4
- export {
5
- SDK_VERSION
6
- };
7
- //# sourceMappingURL=chunk-GQB7N5CJ.js.map