@rovenue/react-native-sdk 0.23.1 → 0.24.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/android/src/main/java/dev/rovenue/sdkrn/RovenueModule.kt +95 -1
- package/dist/chunk-ETC46J2X.js +7 -0
- package/dist/{chunk-GQB7N5CJ.js.map → chunk-ETC46J2X.js.map} +1 -1
- package/dist/index.cjs +76 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +104 -6
- package/dist/index.d.ts +104 -6
- package/dist/index.js +75 -1
- package/dist/index.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/ios/PrivacyInfo.xcprivacy +17 -0
- package/ios/RovenueModule.swift +107 -1
- package/package.json +1 -1
- package/dist/chunk-GQB7N5CJ.js +0 -7
|
@@ -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>
|
package/ios/RovenueModule.swift
CHANGED
|
@@ -289,6 +289,21 @@ public class RovenueModule: Module {
|
|
|
289
289
|
throw RovenueCodedError(e)
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
+
AsyncFunction("preloadPlacement") { (placementId: String, locale: String?) in
|
|
293
|
+
guard #available(iOS 15.0, macOS 12.0, *) else { return }
|
|
294
|
+
await Rovenue.shared.preloadPlacement(placementId, locale: locale)
|
|
295
|
+
}
|
|
296
|
+
AsyncFunction("presentFunnel") { (presentationId: String, placement: String, locale: String?, styleJson: String?, callbacks: [String: Bool]) -> [String: Any?] in
|
|
297
|
+
guard #available(iOS 15.0, *) else {
|
|
298
|
+
return ["result": "unavailable", "purchased": false, "reason": FunnelPresentResult.noPresenter]
|
|
299
|
+
}
|
|
300
|
+
return await self.presentFunnel(
|
|
301
|
+
presentationId: presentationId, placement: placement, locale: locale,
|
|
302
|
+
styleJson: styleJson, callbacks: callbacks)
|
|
303
|
+
}
|
|
304
|
+
AsyncFunction("resolveFunnelPurchaseRequest") { (requestId: String, purchased: Bool) in
|
|
305
|
+
await FunnelPurchaseRequests.shared.resolve(requestId, purchased: purchased)
|
|
306
|
+
}
|
|
292
307
|
AsyncFunction("purchase") { (productId: String, productType: String, promotionalOfferId: String?, basePlanId: String?, offerId: String?) -> [String: Any?] in
|
|
293
308
|
// basePlanId/offerId select a Play subscription offer on Android; ignored on iOS.
|
|
294
309
|
guard #available(iOS 15.0, macOS 12.0, *) else {
|
|
@@ -437,7 +452,7 @@ public class RovenueModule: Module {
|
|
|
437
452
|
}
|
|
438
453
|
|
|
439
454
|
// ---------------- Events ----------------
|
|
440
|
-
Events("onChange", "onLog", "onFunnelClaimResolved")
|
|
455
|
+
Events("onChange", "onLog", "onFunnelClaimResolved", "onFunnelPresentEvent")
|
|
441
456
|
|
|
442
457
|
OnStartObserving {
|
|
443
458
|
self.changesTask = Task { [weak self] in
|
|
@@ -747,3 +762,94 @@ public class RovenueModule: Module {
|
|
|
747
762
|
}
|
|
748
763
|
}
|
|
749
764
|
}
|
|
765
|
+
|
|
766
|
+
// MARK: - presentFunnel (spec 2026-11-03-funnel-presentation §2a)
|
|
767
|
+
|
|
768
|
+
/// Purchase / restore requests a presented funnel is waiting on, answered
|
|
769
|
+
/// from JS by `resolveFunnelPurchaseRequest`. Main-actor isolated: no lock.
|
|
770
|
+
@MainActor
|
|
771
|
+
final class FunnelPurchaseRequests {
|
|
772
|
+
static let shared = FunnelPurchaseRequests()
|
|
773
|
+
private var pending: [String: CheckedContinuation<Bool, Never>] = [:]
|
|
774
|
+
private var serial = 0
|
|
775
|
+
|
|
776
|
+
/// Emits a request through `send` and waits for JS's answer.
|
|
777
|
+
func ask(_ send: (String) -> Void) async -> Bool {
|
|
778
|
+
serial += 1
|
|
779
|
+
let requestId = "r\(serial)"
|
|
780
|
+
return await withCheckedContinuation { continuation in
|
|
781
|
+
pending[requestId] = continuation
|
|
782
|
+
send(requestId)
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
func resolve(_ requestId: String, purchased: Bool) {
|
|
787
|
+
pending.removeValue(forKey: requestId)?.resume(returning: purchased)
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
extension RovenueModule {
|
|
792
|
+
@available(iOS 15.0, *)
|
|
793
|
+
@MainActor
|
|
794
|
+
func presentFunnel(
|
|
795
|
+
presentationId: String, placement: String, locale: String?, styleJson: String?, callbacks: [String: Bool]
|
|
796
|
+
) async -> [String: Any?] {
|
|
797
|
+
let emit: ([String: Any?]) -> Void = { [weak self] body in
|
|
798
|
+
var payload = body
|
|
799
|
+
payload["presentationId"] = presentationId
|
|
800
|
+
self?.sendEvent("onFunnelPresentEvent", payload as [String: Any])
|
|
801
|
+
}
|
|
802
|
+
var handlers = FunnelPresentHandlers()
|
|
803
|
+
if callbacks["onPurchase"] == true {
|
|
804
|
+
handlers.onPurchase = { packageId in
|
|
805
|
+
await FunnelPurchaseRequests.shared.ask { id in
|
|
806
|
+
emit(["type": "purchaseRequest", "requestId": id, "packageId": packageId])
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
if callbacks["onRestore"] == true {
|
|
811
|
+
handlers.onRestore = {
|
|
812
|
+
await FunnelPurchaseRequests.shared.ask { id in emit(["type": "restoreRequest", "requestId": id]) }
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
handlers.onPurchaseError = { error in emit(["type": "purchaseError", "error": Self.errorDTO(error)]) }
|
|
816
|
+
if callbacks["onUrl"] == true {
|
|
817
|
+
handlers.onUrl = { url in emit(["type": "url", "url": url]) }
|
|
818
|
+
}
|
|
819
|
+
if callbacks["onCustomAction"] == true {
|
|
820
|
+
handlers.onCustomAction = { id, params in emit(["type": "customAction", "actionId": id, "paramsJson": params]) }
|
|
821
|
+
}
|
|
822
|
+
let result = await Rovenue.shared.presentFunnel(
|
|
823
|
+
placement: placement, locale: locale, style: Self.presentationOverride(styleJson), handlers: handlers)
|
|
824
|
+
return [
|
|
825
|
+
"result": result.result.rawValue,
|
|
826
|
+
"purchased": result.purchased,
|
|
827
|
+
"customerInfo": result.customerInfo.map(Self.dtoFromPurchaseResult),
|
|
828
|
+
"lastError": result.lastError.map(Self.errorDTO),
|
|
829
|
+
"reason": result.reason,
|
|
830
|
+
]
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
static func errorDTO(_ error: RovenueError) -> [String: Any?] {
|
|
834
|
+
[
|
|
835
|
+
"kind": String(describing: error.kind),
|
|
836
|
+
"message": error.message,
|
|
837
|
+
"serverCode": error.serverCode,
|
|
838
|
+
"httpStatus": error.httpStatus,
|
|
839
|
+
"retryable": error.isRetryable,
|
|
840
|
+
]
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/// The JS `style` object (a partial presentation, JSON).
|
|
844
|
+
static func presentationOverride(_ json: String?) -> FunnelPresentationOverride? {
|
|
845
|
+
guard let json, let data = json.data(using: .utf8),
|
|
846
|
+
let object = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any]
|
|
847
|
+
else { return nil }
|
|
848
|
+
return FunnelPresentationOverride(
|
|
849
|
+
style: (object["style"] as? String).flatMap(FunnelPresentationStyle.init(rawValue:)),
|
|
850
|
+
enter: (object["enter"] as? String).flatMap(FunnelPresentationEnter.init(rawValue:)),
|
|
851
|
+
detents: (object["detents"] as? [String])?.compactMap(FunnelSheetDetent.init(rawValue:)),
|
|
852
|
+
dismissible: object["dismissible"] as? Bool,
|
|
853
|
+
closeOnPurchase: object["closeOnPurchase"] as? Bool)
|
|
854
|
+
}
|
|
855
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rovenue/react-native-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.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",
|