@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.
- package/CHANGELOG.md +473 -2
- package/LICENSE +21 -0
- package/README.md +279 -47
- package/SwissKnifePurchases.podspec +1 -1
- package/android/build.gradle +24 -2
- package/android/consumer-rules.pro +12 -0
- package/android/src/main/AndroidManifest.xml +15 -1
- package/android/src/main/java/com/swissknife/crashreporting/SKCrashReportingModule.kt +5 -4
- package/android/src/main/java/com/swissknife/purchases/SwissKnifeJson.kt +20 -2
- package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +168 -6
- package/android/src/play/java/com/swissknife/purchases/StoreIntentHandler.kt +7 -0
- package/android/src/rustore/java/com/swissknife/purchases/StoreIntentHandler.kt +9 -0
- package/android/vendor/GENERATED.md +1 -0
- package/android/vendor/java/com/appswissknife/SwissKnife.kt +111 -38
- package/android/vendor/java/com/appswissknife/analytics/SKAnalytics.kt +180 -115
- package/android/vendor/java/com/appswissknife/attributes/AttributesClient.kt +16 -18
- package/android/vendor/java/com/appswissknife/attributes/SetAttributesWorker.kt +13 -13
- package/android/vendor/java/com/appswissknife/attribution/Attribution.kt +56 -25
- package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +1 -1
- package/android/vendor/java/com/appswissknife/crashreporting/SKCrashReporting.kt +365 -206
- package/android/vendor/java/com/appswissknife/entitlements/EntitlementsRepository.kt +195 -26
- package/android/vendor/java/com/appswissknife/identity/Identity.kt +31 -6
- package/android/vendor/java/com/appswissknife/models/PurchasesError.kt +5 -0
- package/android/vendor/java/com/appswissknife/net/BackendHttpClient.kt +56 -31
- package/android/vendor/java/com/appswissknife/net/IngestClient.kt +673 -87
- package/android/vendor/java/com/appswissknife/net/OfflineQueueStore.kt +214 -30
- package/android/vendor/java/com/appswissknife/notifications/NotificationRenderer.kt +195 -0
- package/android/vendor/java/com/appswissknife/notifications/PermissionRequestActivity.kt +60 -0
- package/android/vendor/java/com/appswissknife/notifications/PermissionStatus.kt +41 -0
- package/android/vendor/java/com/appswissknife/notifications/PushEventQueue.kt +143 -0
- package/android/vendor/java/com/appswissknife/notifications/PushPayload.kt +72 -0
- package/android/vendor/java/com/appswissknife/notifications/PushRegistration.kt +89 -0
- package/android/vendor/java/com/appswissknife/notifications/SwissKnifeMessagingService.kt +57 -0
- package/android/vendor/java/com/appswissknife/notifications/SwissKnifeNotifications.kt +438 -0
- package/android/vendor/java/com/appswissknife/offerings/OfferingsRepository.kt +312 -65
- package/android/vendor/java/com/appswissknife/performance/SKPerformance.kt +1 -0
- package/android/vendor/java/com/appswissknife/purchases/BillingClientGateway.kt +705 -96
- package/android/vendor/java/com/appswissknife/purchases/PlayPriceEnrichmentProvider.kt +55 -24
- package/android/vendor/java/com/appswissknife/purchases/ProductKindHint.kt +29 -0
- package/android/vendor/java/com/appswissknife/purchases/PurchasesGateway.kt +24 -0
- package/android/vendor-rustore/AndroidManifest.xml +59 -0
- package/android/vendor-rustore/java/com/appswissknife/rustore/RuStoreGateway.kt +428 -0
- package/android/vendor-rustore/java/com/appswissknife/rustore/RuStoreInitProvider.kt +43 -0
- package/android/vendor-rustore/java/com/appswissknife/rustore/RuStorePriceEnrichmentProvider.kt +85 -0
- package/app.plugin.js +343 -0
- package/ios/SwissKnifeJSON.swift +24 -2
- package/ios/SwissKnifePurchases.m +20 -0
- package/ios/SwissKnifePurchases.swift +97 -3
- package/ios/SwissKnifePushBootstrap.m +34 -0
- package/ios/vendor/GENERATED.md +1 -0
- package/ios/vendor/SwissKnifeiOS/Analytics/SKAnalytics.swift +138 -89
- package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +1 -1
- package/ios/vendor/SwissKnifeiOS/CrashReporting/SKCrashReporting.swift +345 -44
- package/ios/vendor/SwissKnifeiOS/Net/BackendBackoffGate.swift +43 -2
- package/ios/vendor/SwissKnifeiOS/Net/IngestClient.swift +495 -16
- package/ios/vendor/SwissKnifeiOS/Net/OfflineQueueStore.swift +231 -23
- package/ios/vendor/SwissKnifeiOS/Notifications/PushPayload.swift +87 -0
- package/ios/vendor/SwissKnifeiOS/Notifications/PushRegistrar.swift +322 -0
- package/ios/vendor/SwissKnifeiOS/Notifications/SwissKnife+Notifications.swift +403 -0
- package/ios/vendor/SwissKnifeiOS/Performance/SKPerformance.swift +1 -0
- package/ios/vendor/SwissKnifeiOS/Services/EntitlementsService.swift +11 -7
- package/ios/vendor/SwissKnifeiOS/Services/OfferingsService.swift +37 -5
- package/ios/vendor/SwissKnifeiOS/Services/PurchaseService.swift +38 -7
- package/ios/vendor/SwissKnifeiOS/SwissKnife.swift +34 -6
- package/ios/vendor/SwissKnifeiOS/Types.swift +31 -1
- package/ios-notification-service/SwissKnifeNotificationService.podspec +37 -0
- package/ios-notification-service/vendor/GENERATED.md +11 -0
- package/ios-notification-service/vendor/SwissKnifeNotificationService/SwissKnifeNotificationServiceExtension.swift +177 -0
- package/lib/commonjs/attribution.js +4 -3
- package/lib/commonjs/attribution.js.map +1 -1
- package/lib/commonjs/identity.js +12 -11
- package/lib/commonjs/identity.js.map +1 -1
- package/lib/commonjs/index.js +16 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/config.js +105 -8
- package/lib/commonjs/internal/config.js.map +1 -1
- package/lib/commonjs/internal/telemetry-context.js +70 -0
- package/lib/commonjs/internal/telemetry-context.js.map +1 -0
- package/lib/commonjs/modules/analytics.js +18 -25
- package/lib/commonjs/modules/analytics.js.map +1 -1
- package/lib/commonjs/modules/crash-reporting.js +27 -6
- package/lib/commonjs/modules/crash-reporting.js.map +1 -1
- package/lib/commonjs/modules/log.js +1 -1
- package/lib/commonjs/modules/notifications.js +500 -0
- package/lib/commonjs/modules/notifications.js.map +1 -0
- package/lib/commonjs/modules/performance.js +57 -8
- package/lib/commonjs/modules/performance.js.map +1 -1
- package/lib/commonjs/native/module.js +6 -0
- package/lib/commonjs/native/module.js.map +1 -1
- package/lib/commonjs/native/spec.js +12 -5
- package/lib/commonjs/native/spec.js.map +1 -1
- package/lib/commonjs/purchases.js +4 -4
- package/lib/commonjs/types.js +12 -15
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/attribution.js +4 -3
- package/lib/module/attribution.js.map +1 -1
- package/lib/module/identity.js +12 -11
- package/lib/module/identity.js.map +1 -1
- package/lib/module/index.js +8 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/config.js +103 -8
- package/lib/module/internal/config.js.map +1 -1
- package/lib/module/internal/telemetry-context.js +63 -0
- package/lib/module/internal/telemetry-context.js.map +1 -0
- package/lib/module/modules/analytics.js +18 -25
- package/lib/module/modules/analytics.js.map +1 -1
- package/lib/module/modules/crash-reporting.js +27 -6
- package/lib/module/modules/crash-reporting.js.map +1 -1
- package/lib/module/modules/log.js +1 -1
- package/lib/module/modules/notifications.js +491 -0
- package/lib/module/modules/notifications.js.map +1 -0
- package/lib/module/modules/performance.js +57 -8
- package/lib/module/modules/performance.js.map +1 -1
- package/lib/module/native/module.js +6 -1
- package/lib/module/native/module.js.map +1 -1
- package/lib/module/native/spec.js +11 -4
- package/lib/module/native/spec.js.map +1 -1
- package/lib/module/purchases.js +4 -4
- package/lib/module/types.js +12 -15
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/attribution.d.ts +3 -2
- package/lib/typescript/commonjs/attribution.d.ts.map +1 -1
- package/lib/typescript/commonjs/identity.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/config.d.ts +16 -2
- package/lib/typescript/commonjs/internal/config.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/telemetry-context.d.ts +22 -0
- package/lib/typescript/commonjs/internal/telemetry-context.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/analytics.d.ts +8 -11
- package/lib/typescript/commonjs/modules/analytics.d.ts.map +1 -1
- package/lib/typescript/commonjs/modules/crash-reporting.d.ts +18 -5
- package/lib/typescript/commonjs/modules/crash-reporting.d.ts.map +1 -1
- package/lib/typescript/commonjs/modules/notifications.d.ts +110 -0
- package/lib/typescript/commonjs/modules/notifications.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/performance.d.ts +13 -0
- package/lib/typescript/commonjs/modules/performance.d.ts.map +1 -1
- package/lib/typescript/commonjs/native/module.d.ts +2 -0
- package/lib/typescript/commonjs/native/module.d.ts.map +1 -1
- package/lib/typescript/commonjs/native/spec.d.ts +33 -4
- package/lib/typescript/commonjs/native/spec.d.ts.map +1 -1
- package/lib/typescript/commonjs/purchases.d.ts +4 -4
- package/lib/typescript/commonjs/types.d.ts +4 -5
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/module/attribution.d.ts +3 -2
- package/lib/typescript/module/attribution.d.ts.map +1 -1
- package/lib/typescript/module/identity.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +2 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/internal/config.d.ts +16 -2
- package/lib/typescript/module/internal/config.d.ts.map +1 -1
- package/lib/typescript/module/internal/telemetry-context.d.ts +22 -0
- package/lib/typescript/module/internal/telemetry-context.d.ts.map +1 -0
- package/lib/typescript/module/modules/analytics.d.ts +8 -11
- package/lib/typescript/module/modules/analytics.d.ts.map +1 -1
- package/lib/typescript/module/modules/crash-reporting.d.ts +18 -5
- package/lib/typescript/module/modules/crash-reporting.d.ts.map +1 -1
- package/lib/typescript/module/modules/notifications.d.ts +110 -0
- package/lib/typescript/module/modules/notifications.d.ts.map +1 -0
- package/lib/typescript/module/modules/performance.d.ts +13 -0
- package/lib/typescript/module/modules/performance.d.ts.map +1 -1
- package/lib/typescript/module/native/module.d.ts +2 -0
- package/lib/typescript/module/native/module.d.ts.map +1 -1
- package/lib/typescript/module/native/spec.d.ts +33 -4
- package/lib/typescript/module/native/spec.d.ts.map +1 -1
- package/lib/typescript/module/purchases.d.ts +4 -4
- package/lib/typescript/module/types.d.ts +4 -5
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/package.json +13 -4
- package/src/attribution.ts +4 -3
- package/src/identity.ts +12 -11
- package/src/index.ts +16 -4
- package/src/internal/config.ts +113 -8
- package/src/internal/telemetry-context.ts +76 -0
- package/src/modules/analytics.ts +24 -33
- package/src/modules/crash-reporting.ts +50 -9
- package/src/modules/log.ts +1 -1
- package/src/modules/notifications.ts +557 -0
- package/src/modules/performance.ts +94 -14
- package/src/native/module.ts +6 -0
- package/src/native/spec.ts +45 -10
- package/src/purchases.ts +4 -4
- package/src/types.ts +12 -15
- package/android/vendor/java/com/appswissknife/analytics/EventQueueStore.kt +0 -326
- package/android/vendor/java/com/appswissknife/analytics/FlushEventsWorker.kt +0 -296
|
@@ -86,7 +86,7 @@ public final class SwissKnife: NSObject {
|
|
|
86
86
|
logLevel: String? = nil,
|
|
87
87
|
attribution: SwissKnife.Attribution.Configuration = .init()
|
|
88
88
|
) {
|
|
89
|
-
|
|
89
|
+
if rejectsBlankApiKey(apiKey, entryPoint: "configure") { return }
|
|
90
90
|
os_log(
|
|
91
91
|
"SwissKnife.configure called (apiKey prefix %{public}@…, proxyURL %{public}@)",
|
|
92
92
|
log: shared.log,
|
|
@@ -139,7 +139,7 @@ public final class SwissKnife: NSObject {
|
|
|
139
139
|
logLevel: String? = nil,
|
|
140
140
|
attribution: SwissKnife.Attribution.Configuration = .init()
|
|
141
141
|
) {
|
|
142
|
-
|
|
142
|
+
if rejectsBlankApiKey(apiKey, entryPoint: "configureCore") { return }
|
|
143
143
|
|
|
144
144
|
let level = logLevel.flatMap(parseLogLevel) ?? .warn
|
|
145
145
|
let (resolvedAppUserID, isAnonymous) = resolveConfiguredIdentity(appUserID)
|
|
@@ -182,6 +182,9 @@ public final class SwissKnife: NSObject {
|
|
|
182
182
|
// config seeding inside is a no-op here because `coreConfigured` is
|
|
183
183
|
// already true by this point, so configureCore's apiKey/serverURL stand.
|
|
184
184
|
ensureObservabilityBackend(apiKey: apiKey, serverURL: proxyURL)
|
|
185
|
+
// Push: if this install has used swiss-push before, resume
|
|
186
|
+
// foreground re-sync and drain queued events. No-op otherwise.
|
|
187
|
+
Notifications.resumeIfEngaged()
|
|
185
188
|
}
|
|
186
189
|
|
|
187
190
|
/// Configure the purchase engine: StoreKit 2 transaction observation,
|
|
@@ -207,7 +210,7 @@ public final class SwissKnife: NSObject {
|
|
|
207
210
|
proxyURL: String? = nil,
|
|
208
211
|
storeKitVersion: String = "DEFAULT"
|
|
209
212
|
) {
|
|
210
|
-
|
|
213
|
+
if rejectsBlankApiKey(apiKey, entryPoint: "configurePurchases") { return }
|
|
211
214
|
os_log(
|
|
212
215
|
"SwissKnife.configurePurchases called (apiKey prefix %{public}@…, proxyURL %{public}@)",
|
|
213
216
|
log: shared.log,
|
|
@@ -251,6 +254,25 @@ public final class SwissKnife: NSObject {
|
|
|
251
254
|
SwissKnife.Attribution._sendInstallOnFirstLaunchIfEnabled()
|
|
252
255
|
}
|
|
253
256
|
|
|
257
|
+
/// True (after logging an error) when `apiKey` is empty or whitespace.
|
|
258
|
+
///
|
|
259
|
+
/// `configure`, `configureCore` and `configurePurchases` call this first
|
|
260
|
+
/// and return without changing any state when it is true. A blank key is
|
|
261
|
+
/// almost always a build-time value that was not set; the `precondition`
|
|
262
|
+
/// that used to sit here trapped in release builds and crashed the host
|
|
263
|
+
/// app at launch, and configuring with the key would mark the SDK
|
|
264
|
+
/// configured with a key the backend refuses. Left unconfigured, a later
|
|
265
|
+
/// call with the real key still configures everything. Android does the
|
|
266
|
+
/// same (`SwissKnife.rejectsBlankApiKey`).
|
|
267
|
+
private static func rejectsBlankApiKey(_ apiKey: String, entryPoint: String) -> Bool {
|
|
268
|
+
guard apiKey.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { return false }
|
|
269
|
+
SKLog.error(
|
|
270
|
+
"SwissKnife.\(entryPoint) was called with an empty apiKey; nothing was configured. "
|
|
271
|
+
+ "Pass the project's SDK key."
|
|
272
|
+
)
|
|
273
|
+
return true
|
|
274
|
+
}
|
|
275
|
+
|
|
254
276
|
/// Resolve `(appUserID, isAnonymous)` the way both configure entry points
|
|
255
277
|
/// need it. Anonymous flow uses the keychain-backed device id, prefixed to
|
|
256
278
|
/// match the convention upstream consumers grep for (similar to RC's
|
|
@@ -299,7 +321,7 @@ public final class SwissKnife: NSObject {
|
|
|
299
321
|
/// inside `makeRequest`, so a *late* configure retroactively unblocks
|
|
300
322
|
/// everything already sitting in the durable ingest queue — nothing that
|
|
301
323
|
/// was tracked before the SDK knew its apiKey is lost.
|
|
302
|
-
/// - An empty `apiKey` is rejected (no-op): wiring the pipeline against a
|
|
324
|
+
/// - An empty or whitespace `apiKey` is rejected (no-op): wiring the pipeline against a
|
|
303
325
|
/// key that can never authenticate would just re-create the silent
|
|
304
326
|
/// failure this method exists to remove.
|
|
305
327
|
///
|
|
@@ -313,11 +335,11 @@ public final class SwissKnife: NSObject {
|
|
|
313
335
|
/// background, plus the JS-side interval calling `flushEvents`.
|
|
314
336
|
///
|
|
315
337
|
/// - Parameters:
|
|
316
|
-
/// - apiKey: the project's SDK key. Empty ⇒ no-op.
|
|
338
|
+
/// - apiKey: the project's SDK key. Empty or whitespace ⇒ no-op.
|
|
317
339
|
/// - serverURL: backend base URL. `nil` / empty ⇒ the default host
|
|
318
340
|
/// (`https://api.swiss-knife.dev`), matching `configure(proxyURL:)`.
|
|
319
341
|
public static func ensureObservabilityBackend(apiKey: String, serverURL: String?) {
|
|
320
|
-
guard !apiKey.isEmpty else { return }
|
|
342
|
+
guard !apiKey.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { return }
|
|
321
343
|
let normalizedServerURL: String? = {
|
|
322
344
|
guard var trimmed = serverURL?.trimmingCharacters(in: .whitespacesAndNewlines) else {
|
|
323
345
|
return nil
|
|
@@ -568,6 +590,7 @@ public final class SwissKnife: NSObject {
|
|
|
568
590
|
shared.currentAppUserID = userId
|
|
569
591
|
shared.currentIsAnonymous = false
|
|
570
592
|
}
|
|
593
|
+
Notifications.identityChanged()
|
|
571
594
|
}
|
|
572
595
|
|
|
573
596
|
/// Update legacy state after a transition to the anonymous identity.
|
|
@@ -576,6 +599,7 @@ public final class SwissKnife: NSObject {
|
|
|
576
599
|
shared.currentAppUserID = anonymousId
|
|
577
600
|
shared.currentIsAnonymous = true
|
|
578
601
|
}
|
|
602
|
+
Notifications.identityChanged(loggedOut: true)
|
|
579
603
|
}
|
|
580
604
|
|
|
581
605
|
/// Test seam — drops the SDK's configured state. Used by tests that
|
|
@@ -606,6 +630,7 @@ public final class SwissKnife: NSObject {
|
|
|
606
630
|
shared.currentAppUserID = anonId
|
|
607
631
|
shared.currentIsAnonymous = true
|
|
608
632
|
}
|
|
633
|
+
Notifications.identityChanged(loggedOut: true)
|
|
609
634
|
}
|
|
610
635
|
|
|
611
636
|
// MARK: Subscriber attributes (unchanged from Phase 3 — AttributesClient)
|
|
@@ -643,6 +668,9 @@ public final class SwissKnife: NSObject {
|
|
|
643
668
|
userId: currentExternalUserIdForAttributes()
|
|
644
669
|
)
|
|
645
670
|
}
|
|
671
|
+
/// Legacy: stores the token as a `$pushToken` subscriber attribute only.
|
|
672
|
+
/// It does NOT register the device with swiss-push.
|
|
673
|
+
@available(*, deprecated, message: "Use SwissKnife.Notifications.registerDeviceToken(_:) — it registers the device for push sends and tracking.")
|
|
646
674
|
public static func setPushToken(_ pushToken: String?) {
|
|
647
675
|
AttributesClient.shared.set(
|
|
648
676
|
reservedKey: "$pushToken",
|
|
@@ -158,6 +158,28 @@ public struct StoreProductDiscount: Sendable, Codable, Equatable {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
// MARK: - StoreProductType
|
|
162
|
+
|
|
163
|
+
/// What kind of in-app product a `StoreProduct` is: StoreKit 2's
|
|
164
|
+
/// `Product.ProductType`, without importing StoreKit. Raw values are the
|
|
165
|
+
/// backend's product-type vocabulary (`auto_renewable`, `non_renewing`,
|
|
166
|
+
/// `consumable`, `non_consumable`).
|
|
167
|
+
public enum StoreProductType: String, Sendable, Codable, CaseIterable {
|
|
168
|
+
case autoRenewableSubscription = "auto_renewable"
|
|
169
|
+
case nonRenewableSubscription = "non_renewing"
|
|
170
|
+
case consumable
|
|
171
|
+
case nonConsumable = "non_consumable"
|
|
172
|
+
/// Not known: a StoreKit type this SDK does not recognise, or a one-time
|
|
173
|
+
/// product described only by the backend, which does not say whether it
|
|
174
|
+
/// is consumable.
|
|
175
|
+
case unknown
|
|
176
|
+
|
|
177
|
+
/// True only for an auto-renewable subscription (RevenueCat's
|
|
178
|
+
/// `ProductCategory.subscription`). A non-renewing subscription is a
|
|
179
|
+
/// one-time purchase with no billing period, as consumables are.
|
|
180
|
+
public var isSubscription: Bool { self == .autoRenewableSubscription }
|
|
181
|
+
}
|
|
182
|
+
|
|
161
183
|
// MARK: - StoreProduct
|
|
162
184
|
|
|
163
185
|
/// A single product as returned by the App Store. We populate this directly
|
|
@@ -173,9 +195,14 @@ public struct StoreProduct: Sendable, Equatable {
|
|
|
173
195
|
/// Pre-formatted display price (e.g. `"$9.99"`) — passes through StoreKit's
|
|
174
196
|
/// localized formatter so we don't re-derive the locale ourselves.
|
|
175
197
|
public let displayPrice: String
|
|
198
|
+
/// The SDK sets this only for an auto-renewable subscription.
|
|
176
199
|
public let subscriptionPeriod: SubscriptionPeriod?
|
|
200
|
+
/// The SDK sets this only for an auto-renewable subscription.
|
|
177
201
|
public let introductoryDiscount: StoreProductDiscount?
|
|
178
202
|
public let discounts: [StoreProductDiscount]
|
|
203
|
+
/// StoreKit's product type (`Product.type`), or what the backend says for
|
|
204
|
+
/// a product StoreKit did not return.
|
|
205
|
+
public let productType: StoreProductType
|
|
179
206
|
|
|
180
207
|
/// Number formatter pre-configured for this product's currency. Recreating
|
|
181
208
|
/// it on demand is cheap; we surface it so consumers can format derived
|
|
@@ -196,7 +223,9 @@ public struct StoreProduct: Sendable, Equatable {
|
|
|
196
223
|
displayPrice: String,
|
|
197
224
|
subscriptionPeriod: SubscriptionPeriod?,
|
|
198
225
|
introductoryDiscount: StoreProductDiscount?,
|
|
199
|
-
discounts: [StoreProductDiscount]
|
|
226
|
+
discounts: [StoreProductDiscount],
|
|
227
|
+
// Defaulted so code that builds a StoreProduct by hand keeps compiling.
|
|
228
|
+
productType: StoreProductType = .unknown
|
|
200
229
|
) {
|
|
201
230
|
self.productIdentifier = productIdentifier
|
|
202
231
|
self.localizedTitle = localizedTitle
|
|
@@ -207,6 +236,7 @@ public struct StoreProduct: Sendable, Equatable {
|
|
|
207
236
|
self.subscriptionPeriod = subscriptionPeriod
|
|
208
237
|
self.introductoryDiscount = introductoryDiscount
|
|
209
238
|
self.discounts = discounts
|
|
239
|
+
self.productType = productType
|
|
210
240
|
}
|
|
211
241
|
}
|
|
212
242
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# packages/react-native-sdk/ios-notification-service/SwissKnifeNotificationService.podspec
|
|
2
|
+
#
|
|
3
|
+
# Notification Service Extension base class for swiss-push rich notifications,
|
|
4
|
+
# shipped in the npm package so a React Native app can add it from
|
|
5
|
+
# node_modules. In the app's Podfile, inside the extension's target:
|
|
6
|
+
#
|
|
7
|
+
# target 'YourNotificationService' do
|
|
8
|
+
# pod 'SwissKnifeNotificationService', :path => '../node_modules/@app-swiss-knife/react-native-sdk/ios-notification-service'
|
|
9
|
+
# end
|
|
10
|
+
#
|
|
11
|
+
# Foundation + UserNotifications only, so the extension stays under its memory
|
|
12
|
+
# cap. The sources under vendor/ are copied from
|
|
13
|
+
# packages/swiss-knife-ios/Sources/SwissKnifeNotificationService by
|
|
14
|
+
# scripts/vendor-native.mjs at build/prepack time (gitignored here).
|
|
15
|
+
#
|
|
16
|
+
# This podspec lives in its own folder on purpose. React Native and Expo
|
|
17
|
+
# autolinking link the FIRST *.podspec at the package root into the app target
|
|
18
|
+
# (Expo sorts them, and "SwissKnifeNotificationService" sorts before
|
|
19
|
+
# "SwissKnifePurchases"), so a second podspec at the root would replace the
|
|
20
|
+
# SDK's pod in every app. Keep exactly one podspec at the root. For the same
|
|
21
|
+
# reason, the folder is not under ios/, which SwissKnifePurchases.podspec
|
|
22
|
+
# compiles whole (`ios/**`): the app pod must not gain this extension class.
|
|
23
|
+
Pod::Spec.new do |s|
|
|
24
|
+
s.name = "SwissKnifeNotificationService"
|
|
25
|
+
s.version = "0.5.1"
|
|
26
|
+
s.summary = "Swiss Knife push: UNNotificationServiceExtension base class (image attachments, received tracking)."
|
|
27
|
+
s.homepage = "https://github.com/Remneys/swiss-knife"
|
|
28
|
+
s.license = "MIT"
|
|
29
|
+
s.authors = "App Swiss Knife"
|
|
30
|
+
s.platforms = { :ios => "15.0" }
|
|
31
|
+
s.source = { :git => "https://github.com/Remneys/swiss-knife.git", :tag => "#{s.version}" }
|
|
32
|
+
s.source_files = "vendor/SwissKnifeNotificationService/**/*.swift"
|
|
33
|
+
s.swift_version = "5.9"
|
|
34
|
+
s.frameworks = "UserNotifications"
|
|
35
|
+
# App extensions may only link extension-safe API.
|
|
36
|
+
s.pod_target_xcconfig = { "APPLICATION_EXTENSION_API_ONLY" => "YES" }
|
|
37
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
GENERATED — DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
Copied verbatim by packages/react-native-sdk/scripts/vendor-native.mjs from the
|
|
4
|
+
standalone native SDK sources in the monorepo. Edit those instead:
|
|
5
|
+
|
|
6
|
+
packages/swiss-knife-ios/Sources/SwissKnifeiOS/**
|
|
7
|
+
packages/swiss-knife-ios/Sources/SwissKnifeNotificationService/**
|
|
8
|
+
packages/swiss-knife-android/src/main/{java,res}/**
|
|
9
|
+
|
|
10
|
+
This directory is gitignored and regenerated on every `build` / `prepack`.
|
|
11
|
+
It ships inside the npm tarball so the package is self-contained.
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// packages/swiss-knife-ios/Sources/SwissKnifeNotificationService/SwissKnifeNotificationServiceExtension.swift
|
|
2
|
+
//
|
|
3
|
+
// Drop-in `UNNotificationServiceExtension` for swiss-push rich notifications.
|
|
4
|
+
//
|
|
5
|
+
// This target is deliberately SELF-CONTAINED — it imports only Foundation and
|
|
6
|
+
// UserNotifications and does NOT link the main `SwissKnifeiOS` library, so the
|
|
7
|
+
// extension binary stays tiny (extensions have a hard ~24 MB memory cap).
|
|
8
|
+
//
|
|
9
|
+
// Usage (in your Notification Service Extension target):
|
|
10
|
+
//
|
|
11
|
+
// import SwissKnifeNotificationService
|
|
12
|
+
// final class NotificationService: SwissKnifeNotificationServiceExtension {
|
|
13
|
+
// // OPTIONAL — enables `received` tracking from the extension:
|
|
14
|
+
// override var trackingConfiguration: TrackingConfiguration? {
|
|
15
|
+
// .init(apiKey: "sk_live_...", baseURL: URL(string: "https://api.swiss-knife.dev")!)
|
|
16
|
+
// }
|
|
17
|
+
// }
|
|
18
|
+
//
|
|
19
|
+
// It downloads `sk.img` and attaches it, inside the OS time budget.
|
|
20
|
+
|
|
21
|
+
import Foundation
|
|
22
|
+
import UserNotifications
|
|
23
|
+
|
|
24
|
+
open class SwissKnifeNotificationServiceExtension: UNNotificationServiceExtension {
|
|
25
|
+
|
|
26
|
+
public struct TrackingConfiguration: Sendable {
|
|
27
|
+
public let apiKey: String
|
|
28
|
+
public let baseURL: URL
|
|
29
|
+
public init(apiKey: String, baseURL: URL) {
|
|
30
|
+
self.apiKey = apiKey
|
|
31
|
+
self.baseURL = baseURL
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// Override to also record `received` for every delivery (the main app
|
|
36
|
+
/// only sees foreground deliveries). nil (default) = no network call
|
|
37
|
+
/// besides the image download.
|
|
38
|
+
open var trackingConfiguration: TrackingConfiguration? { nil }
|
|
39
|
+
|
|
40
|
+
/// Seconds allowed for the image download. iOS gives the extension ~30s;
|
|
41
|
+
/// keep a safety margin.
|
|
42
|
+
open var imageTimeout: TimeInterval { 20 }
|
|
43
|
+
|
|
44
|
+
// `didReceive` work (a Task) and `serviceExtensionTimeWillExpire` (system
|
|
45
|
+
// thread) race to deliver; the handler must be called exactly once, and the
|
|
46
|
+
// content must not be mutated while it is being handed over.
|
|
47
|
+
private let state = NSLock()
|
|
48
|
+
private var contentHandler: ((UNNotificationContent) -> Void)?
|
|
49
|
+
private var bestAttempt: UNMutableNotificationContent?
|
|
50
|
+
private var work: Task<Void, Never>?
|
|
51
|
+
|
|
52
|
+
open override func didReceive(
|
|
53
|
+
_ request: UNNotificationRequest,
|
|
54
|
+
withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
|
|
55
|
+
) {
|
|
56
|
+
let content = (request.content.mutableCopy() as? UNMutableNotificationContent) ?? UNMutableNotificationContent()
|
|
57
|
+
setUp(handler: contentHandler, content: content)
|
|
58
|
+
|
|
59
|
+
let meta = SKPushMeta.parse(request.content.userInfo)
|
|
60
|
+
guard let meta else { return finish(attaching: nil) }
|
|
61
|
+
|
|
62
|
+
work = Task { [weak self] in
|
|
63
|
+
guard let self else { return }
|
|
64
|
+
async let attachment: UNNotificationAttachment? = {
|
|
65
|
+
guard let img = meta.imageURL else { return nil }
|
|
66
|
+
return await SKImageAttachment.download(img, timeout: self.imageTimeout)
|
|
67
|
+
}()
|
|
68
|
+
async let tracked: Void = {
|
|
69
|
+
if let cfg = self.trackingConfiguration {
|
|
70
|
+
await SKReceivedReporter.report(meta, config: cfg)
|
|
71
|
+
}
|
|
72
|
+
}()
|
|
73
|
+
let a = await attachment
|
|
74
|
+
_ = await tracked
|
|
75
|
+
self.finish(attaching: a)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
open override func serviceExtensionTimeWillExpire() {
|
|
80
|
+
work?.cancel()
|
|
81
|
+
finish(attaching: nil)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private func setUp(handler: @escaping (UNNotificationContent) -> Void, content: UNMutableNotificationContent) {
|
|
85
|
+
state.lock(); defer { state.unlock() }
|
|
86
|
+
contentHandler = handler
|
|
87
|
+
bestAttempt = content
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// Delivers the content once. The first caller wins; later callers no-op.
|
|
91
|
+
private func finish(attaching attachment: UNNotificationAttachment?) {
|
|
92
|
+
state.lock()
|
|
93
|
+
guard let handler = contentHandler, let content = bestAttempt else { state.unlock(); return }
|
|
94
|
+
contentHandler = nil
|
|
95
|
+
if let attachment { content.attachments = [attachment] }
|
|
96
|
+
state.unlock()
|
|
97
|
+
handler(content)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// MARK: - Payload
|
|
102
|
+
|
|
103
|
+
internal struct SKPushMeta: Equatable {
|
|
104
|
+
let messageId: String
|
|
105
|
+
let deliveryId: String
|
|
106
|
+
let imageURL: URL?
|
|
107
|
+
|
|
108
|
+
static func parse(_ userInfo: [AnyHashable: Any]) -> SKPushMeta? {
|
|
109
|
+
guard let sk = userInfo["sk"] as? [String: Any],
|
|
110
|
+
let m = sk["m"] as? String, !m.isEmpty,
|
|
111
|
+
let d = sk["d"] as? String, !d.isEmpty
|
|
112
|
+
else { return nil }
|
|
113
|
+
let img = (sk["img"] as? String).flatMap { $0.isEmpty ? nil : URL(string: $0) }
|
|
114
|
+
return SKPushMeta(messageId: m, deliveryId: d, imageURL: img.flatMap { $0.scheme == "https" ? $0 : nil })
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// MARK: - Image download
|
|
119
|
+
|
|
120
|
+
internal enum SKImageAttachment {
|
|
121
|
+
|
|
122
|
+
static func fileExtension(mimeType: String?, url: URL) -> String {
|
|
123
|
+
switch mimeType?.lowercased().split(separator: ";").first.map(String.init) {
|
|
124
|
+
case "image/jpeg", "image/jpg": return "jpg"
|
|
125
|
+
case "image/png": return "png"
|
|
126
|
+
case "image/gif": return "gif"
|
|
127
|
+
case "image/heic": return "heic"
|
|
128
|
+
case "image/webp": return "webp"
|
|
129
|
+
default:
|
|
130
|
+
let ext = url.pathExtension.lowercased()
|
|
131
|
+
return ext.isEmpty ? "jpg" : ext
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static func download(_ url: URL, timeout: TimeInterval) async -> UNNotificationAttachment? {
|
|
136
|
+
var request = URLRequest(url: url)
|
|
137
|
+
request.timeoutInterval = timeout
|
|
138
|
+
do {
|
|
139
|
+
let (tmp, response) = try await URLSession.shared.download(for: request)
|
|
140
|
+
if let http = response as? HTTPURLResponse, !(200...299).contains(http.statusCode) { return nil }
|
|
141
|
+
let ext = fileExtension(mimeType: response.mimeType, url: url)
|
|
142
|
+
let dest = FileManager.default.temporaryDirectory
|
|
143
|
+
.appendingPathComponent("sk-\(UUID().uuidString).\(ext)")
|
|
144
|
+
try FileManager.default.moveItem(at: tmp, to: dest)
|
|
145
|
+
return try UNNotificationAttachment(identifier: "sk-image", url: dest, options: nil)
|
|
146
|
+
} catch {
|
|
147
|
+
return nil
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// MARK: - `received` reporting
|
|
153
|
+
|
|
154
|
+
internal enum SKReceivedReporter {
|
|
155
|
+
static func body(_ meta: SKPushMeta, now: Date = Date()) -> Data? {
|
|
156
|
+
let iso = ISO8601DateFormatter()
|
|
157
|
+
iso.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
|
158
|
+
let event: [String: Any] = [
|
|
159
|
+
"delivery_id": meta.deliveryId,
|
|
160
|
+
"message_id": meta.messageId,
|
|
161
|
+
"type": "received",
|
|
162
|
+
"occurred_at": iso.string(from: now),
|
|
163
|
+
]
|
|
164
|
+
return try? JSONSerialization.data(withJSONObject: ["events": [event]])
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static func report(_ meta: SKPushMeta, config: SwissKnifeNotificationServiceExtension.TrackingConfiguration) async {
|
|
168
|
+
guard let body = body(meta) else { return }
|
|
169
|
+
var request = URLRequest(url: config.baseURL.appendingPathComponent("api/sdk/push/events"))
|
|
170
|
+
request.httpMethod = "POST"
|
|
171
|
+
request.httpBody = body
|
|
172
|
+
request.timeoutInterval = 10
|
|
173
|
+
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
174
|
+
request.setValue(config.apiKey, forHTTPHeaderField: "X-API-Key")
|
|
175
|
+
_ = try? await URLSession.shared.data(for: request)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -7,7 +7,7 @@ exports.Attribution = void 0;
|
|
|
7
7
|
var _module = require("./native/module.js");
|
|
8
8
|
// packages/react-native-sdk/src/attribution.ts
|
|
9
9
|
//
|
|
10
|
-
//
|
|
10
|
+
// The Attribution JS surface. Mirror of
|
|
11
11
|
// `SwissKnife.Attribution` (iOS, Swift) and
|
|
12
12
|
// `com.appswissknife.attribution.Attribution` (Android, Kotlin). All
|
|
13
13
|
// logic lives natively — this module is a thin passthrough.
|
|
@@ -35,8 +35,9 @@ const Attribution = exports.Attribution = {
|
|
|
35
35
|
return (0, _module.getNativeModule)().attributionResolved();
|
|
36
36
|
},
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* Collect what the platform allows (ATT prompt + IDFA on iOS; on Android
|
|
39
|
+
* only what native collectors supply, none by default) and POST
|
|
40
|
+
* `/api/sdk/attribution/install`.
|
|
40
41
|
* Idempotent — second call returns the cached resolution WITHOUT
|
|
41
42
|
* re-prompting or re-POSTing.
|
|
42
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_module","require","Attribution","exports","resolved","getNativeModule","attributionResolved","requestAndRegister","attributionRequestAndRegister","registerInstall","advertisingId","attributionRegisterInstall"],"sourceRoot":"../../src","sources":["attribution.ts"],"mappings":";;;;;;AAoBA,IAAAA,OAAA,GAAAC,OAAA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzB;AACF;AACA;AACA;AACA;EACE,MAAME,QAAQA,CAAA,EAAwC;IACpD,OAAO,IAAAC,uBAAe,EAAC,CAAC,CAACC,mBAAmB,CAAC,CAAC;EAChD,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACE,MAAMC,kBAAkBA,CAAA,EAAwC;IAC9D,OAAO,IAAAF,uBAAe,EAAC,CAAC,CAACG,6BAA6B,CAAC,CAAC;EAC1D,CAAC;EAED;AACF;AACA;AACA;AACA;EACE,MAAMC,eAAeA,CACnBC,aAA6B,EACQ;IACrC,OAAO,IAAAL,uBAAe,EAAC,CAAC,CAACM,0BAA0B,CAACD,aAAa,IAAI,IAAI,CAAC;EAC5E;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_module","require","Attribution","exports","resolved","getNativeModule","attributionResolved","requestAndRegister","attributionRequestAndRegister","registerInstall","advertisingId","attributionRegisterInstall"],"sourceRoot":"../../src","sources":["attribution.ts"],"mappings":";;;;;;AAoBA,IAAAA,OAAA,GAAAC,OAAA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzB;AACF;AACA;AACA;AACA;EACE,MAAME,QAAQA,CAAA,EAAwC;IACpD,OAAO,IAAAC,uBAAe,EAAC,CAAC,CAACC,mBAAmB,CAAC,CAAC;EAChD,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,kBAAkBA,CAAA,EAAwC;IAC9D,OAAO,IAAAF,uBAAe,EAAC,CAAC,CAACG,6BAA6B,CAAC,CAAC;EAC1D,CAAC;EAED;AACF;AACA;AACA;AACA;EACE,MAAMC,eAAeA,CACnBC,aAA6B,EACQ;IACrC,OAAO,IAAAL,uBAAe,EAAC,CAAC,CAACM,0BAA0B,CAACD,aAAa,IAAI,IAAI,CAAC;EAC5E;AACF,CAAC","ignoreList":[]}
|
package/lib/commonjs/identity.js
CHANGED
|
@@ -4,23 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Identity = void 0;
|
|
7
|
+
var _notifications = require("./modules/notifications.js");
|
|
7
8
|
var _module = require("./native/module.js");
|
|
8
9
|
// packages/react-native-sdk/src/identity.ts
|
|
9
10
|
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// passthrough.
|
|
11
|
+
// The `Identity` JS surface. Mirror of `SwissKnife.Identity` on iOS (Swift)
|
|
12
|
+
// and `com.appswissknife.identity.Identity` on Android (Kotlin). All logic
|
|
13
|
+
// lives natively — this module is a thin passthrough.
|
|
14
14
|
//
|
|
15
15
|
// Why JS doesn't keep its own state
|
|
16
16
|
// ---------------------------------
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// the native `Identity.current()` snapshot at event-build time. See
|
|
23
|
-
// `modules/analytics.ts` for that derivation.
|
|
17
|
+
// Native is the single source of truth for who the user is. A JS-local copy
|
|
18
|
+
// would drift from it: an `Analytics.track(...)` right after
|
|
19
|
+
// `Identity.logIn("u_42")` must already carry `u_42`, so `modules/analytics.ts`
|
|
20
|
+
// derives `user_id` from the native `Identity.current()` snapshot at
|
|
21
|
+
// event-build time instead of from any JS state.
|
|
24
22
|
//
|
|
25
23
|
// Observers
|
|
26
24
|
// ---------
|
|
@@ -142,6 +140,7 @@ const Identity = exports.Identity = {
|
|
|
142
140
|
async logOut() {
|
|
143
141
|
lastLogIn = null;
|
|
144
142
|
await (0, _module.getNativeModule)().identityLogOut();
|
|
143
|
+
(0, _notifications.notifyExplicitLogout)();
|
|
145
144
|
await snapshotAndNotify("logOut");
|
|
146
145
|
},
|
|
147
146
|
/**
|
|
@@ -151,6 +150,7 @@ const Identity = exports.Identity = {
|
|
|
151
150
|
async reset() {
|
|
152
151
|
lastLogIn = null;
|
|
153
152
|
await (0, _module.getNativeModule)().identityReset();
|
|
153
|
+
(0, _notifications.notifyExplicitLogout)();
|
|
154
154
|
await snapshotAndNotify("reset");
|
|
155
155
|
},
|
|
156
156
|
/**
|
|
@@ -160,6 +160,7 @@ const Identity = exports.Identity = {
|
|
|
160
160
|
async wipe() {
|
|
161
161
|
lastLogIn = null;
|
|
162
162
|
await (0, _module.getNativeModule)().identityWipe();
|
|
163
|
+
(0, _notifications.notifyExplicitLogout)();
|
|
163
164
|
await snapshotAndNotify("wipe");
|
|
164
165
|
},
|
|
165
166
|
/** Subscribe to identity changes. Returns an unsubscribe token. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_notifications","require","_module","observers","Map","lastSnapshot","lastLogIn","generateToken","replace","c","r","Math","random","v","toString","snapshotAndNotify","reason","previous","current","getNativeModule","identityCurrent","size","change","Promise","resolve","then","observer","values","e","console","warn","Identity","exports","logIn","userId","isAnonymous","result","identityLogIn","logOut","identityLogOut","notifyExplicitLogout","reset","identityReset","wipe","identityWipe","addObserver","block","token","set","removeObserver","delete","__resetForTests","clear"],"sourceRoot":"../../src","sources":["identity.ts"],"mappings":"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","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -15,7 +15,8 @@ var _exportNames = {
|
|
|
15
15
|
CrashReporting: true,
|
|
16
16
|
SKErrorBoundary: true,
|
|
17
17
|
parseStackTrace: true,
|
|
18
|
-
Performance: true
|
|
18
|
+
Performance: true,
|
|
19
|
+
Notifications: true
|
|
19
20
|
};
|
|
20
21
|
Object.defineProperty(exports, "Analytics", {
|
|
21
22
|
enumerable: true,
|
|
@@ -47,6 +48,12 @@ Object.defineProperty(exports, "Identity", {
|
|
|
47
48
|
return _identity.Identity;
|
|
48
49
|
}
|
|
49
50
|
});
|
|
51
|
+
Object.defineProperty(exports, "Notifications", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _notifications.Notifications;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
50
57
|
Object.defineProperty(exports, "Performance", {
|
|
51
58
|
enumerable: true,
|
|
52
59
|
get: function () {
|
|
@@ -110,6 +117,7 @@ var _attribution = require("./attribution.js");
|
|
|
110
117
|
var _analytics = require("./modules/analytics.js");
|
|
111
118
|
var _crashReporting = require("./modules/crash-reporting.js");
|
|
112
119
|
var _performance = require("./modules/performance.js");
|
|
120
|
+
var _notifications = require("./modules/notifications.js");
|
|
113
121
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
114
122
|
// src/index.ts
|
|
115
123
|
// Default export mirrors react-native-purchases: `import Purchases from '...'`.
|
|
@@ -128,14 +136,14 @@ var _default = exports.default = _purchases.default; // Named export of the clas
|
|
|
128
136
|
// `Purchases.setAttributes` / `setEmail` / … aliases are the same functions.
|
|
129
137
|
// Public type/enum/error surface (CustomerInfo, PurchasesOfferings,
|
|
130
138
|
// PURCHASES_ERROR_CODE, LOG_LEVEL, ConfigureOptions, the enums,
|
|
131
|
-
// PurchasesError, etc.) — defined in ./types
|
|
132
|
-
// dependency).
|
|
133
|
-
//
|
|
139
|
+
// PurchasesError, etc.) — defined in ./types, this package's own definitions
|
|
140
|
+
// (no RevenueCat dependency).
|
|
141
|
+
// Identity. Routes through native
|
|
134
142
|
// `SwissKnife.Identity` (iOS) / `com.appswissknife.identity.Identity`
|
|
135
143
|
// (Android). Decoupled from analytics: `Identity.logIn(...)` does NOT
|
|
136
144
|
// auto-emit a `$identify` event; call `Analytics.identify(...)`
|
|
137
145
|
// separately if you want retro-tagging.
|
|
138
|
-
//
|
|
146
|
+
// Attribution. Routes through native
|
|
139
147
|
// `SwissKnife.Attribution` (iOS) / `com.appswissknife.attribution.Attribution`
|
|
140
148
|
// (Android). Native owns the ATT prompt orchestration, IDFA /
|
|
141
149
|
// AdvertisingId / InstallReferrer collection, and the disk-backed
|
|
@@ -144,4 +152,7 @@ var _default = exports.default = _purchases.default; // Named export of the clas
|
|
|
144
152
|
// harness and any consumer that wants analytics / crash-reporting /
|
|
145
153
|
// performance alongside subscriptions. The Purchases surface is the SDK's
|
|
146
154
|
// primary product; these are additive.
|
|
155
|
+
// Push notifications (swiss-push v1). Native mode (SDK owns the OS token) and
|
|
156
|
+
// manual mode (`expo-notifications` / RNFirebase hand us the token) share one
|
|
157
|
+
// API — see README "Push notifications".
|
|
147
158
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_purchases","_interopRequireDefault","require","_swissKnife","_attributes","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_identity","_attribution","_analytics","_crashReporting","_performance","e","__esModule","default","_default","Purchases"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_purchases","_interopRequireDefault","require","_swissKnife","_attributes","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_identity","_attribution","_analytics","_crashReporting","_performance","_notifications","e","__esModule","default","_default","Purchases"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAgBA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,MAAA,GAAAH,OAAA;AAAAI,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAOA,IAAAS,SAAA,GAAAhB,OAAA;AAQA,IAAAiB,YAAA,GAAAjB,OAAA;AAOA,IAAAkB,UAAA,GAAAlB,OAAA;AAEA,IAAAmB,eAAA,GAAAnB,OAAA;AAaA,IAAAoB,YAAA,GAAApB,OAAA;AAWA,IAAAqB,cAAA,GAAArB,OAAA;AAAwD,SAAAD,uBAAAuB,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA7ExD;AAGA;AAAA,IAAAG,QAAA,GAAAb,OAAA,CAAAY,OAAA,GACeE,kBAAS,EAExB;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAwBA;AACA;AACA","ignoreList":[]}
|