Skip to content
Merged

4.0.6 #306

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The changelog for `SuperwallKit`. Also see the [releases](https://github.com/superwall/Superwall-iOS/releases) on GitHub.

## 4.0.6

### Fixes

- Prevents all `purchase(_:)` overrides from being able to be called when the `shouldObservePurchases` `SuperwallOption` is `true`.

## 4.0.5

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion Sources/SuperwallKit/Misc/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ let sdkVersion = """
*/

let sdkVersion = """
4.0.5
4.0.6
"""
78 changes: 45 additions & 33 deletions Sources/SuperwallKit/Superwall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,17 @@ public final class Superwall: NSObject, ObservableObject {
await self.dependencyContainer.delegateAdapter.subscriptionStatusDidChange(
from: oldStatus, to: newStatus)
let event = InternalSuperwallEvent.SubscriptionStatusDidChange(status: newStatus)
await Superwall.shared.track(event)
await self.track(event)
}
Task {
let deviceAttributes = await self.dependencyContainer.makeSessionDeviceAttributes()
let deviceAttributesPlacement = InternalSuperwallEvent.DeviceAttributes(
deviceAttributes: deviceAttributes)
await self.track(deviceAttributesPlacement)
}
}
))
)
)
}

/// Sets ``subscriptionStatus`` to an`unknown` state.
Expand Down Expand Up @@ -701,7 +708,7 @@ public final class Superwall: NSObject, ObservableObject {

// MARK: - External Purchasing

/// Initiates a purchase of a `SKProduct`.
/// Initiates a purchase of a ``StoreProduct``.
///
/// Use this function to purchase a ``StoreProduct``, regardless of whether you
/// have a paywall or not. Superwall will handle the purchase with `StoreKit`
Expand All @@ -712,7 +719,18 @@ public final class Superwall: NSObject, ObservableObject {
/// - Returns: A ``PurchaseResult``.
/// - Note: You only need to finish the transaction after this if you're providing a ``PurchaseController``
/// when configuring the SDK. Otherwise ``Superwall`` will handle this for you.
/// - Warning: You cannot use this function while also setting ``SuperwallOptions/shouldObservePurchases``
/// to `true`.
public func purchase(_ product: StoreProduct) async -> PurchaseResult {
if options.shouldObservePurchases {
Logger.debug(
logLevel: .error,
scope: .superwallCore,
message: "You cannot make purchases using Superwall.shared.purchase(_:) while the "
+ "SuperwallOption shouldObservePurchases is set to true."
)
return .cancelled
}
return await dependencyContainer.transactionManager.purchase(.purchaseFunc(product))
}

Expand All @@ -727,6 +745,8 @@ public final class Superwall: NSObject, ObservableObject {
/// - Returns: A ``PurchaseResult``.
/// - Note: You only need to finish the transaction after this if you're providing a ``PurchaseController``
/// when configuring the SDK. Otherwise ``Superwall`` will handle this for you.
/// - Warning: You cannot use this function while also setting ``SuperwallOptions/shouldObservePurchases``
/// to `true`.
public func purchase(_ product: SKProduct) async -> PurchaseResult {
if options.shouldObservePurchases {
Logger.debug(
Expand Down Expand Up @@ -754,23 +774,34 @@ public final class Superwall: NSObject, ObservableObject {
/// when configuring the SDK. Otherwise ``Superwall`` will handle this for you.
@available(iOS 15.0, *)
public func purchase(_ product: StoreKit.Product) async -> PurchaseResult {
if options.shouldObservePurchases {
Logger.debug(
logLevel: .error,
scope: .superwallCore,
message: "You cannot make purchases using Superwall.shared.purchase(_:) while the "
+ "SuperwallOption shouldObservePurchases is set to true."
)
return .cancelled
}
let storeProduct = StoreProduct(sk2Product: product)
return await dependencyContainer.transactionManager.purchase(.purchaseFunc(storeProduct))
}

/// Initiates a purchase of a `SKProduct`.
/// Initiates a purchase of a ``StoreProduct``.
///
/// Use this function to purchase any `SKProduct`, regardless of whether you
/// Use this function to purchase any ``StoreProduct``, regardless of whether you
/// have a paywall or not. Superwall will handle the purchase with `StoreKit`
/// and return the ``PurchaseResult``. You'll see the data associated with the
/// purchase on the Superwall dashboard.
///
/// - Parameters:
/// - product: The `SKProduct` you wish to purchase.
/// - product: The ``StoreProduct`` you wish to purchase.
/// - completion: A completion block that is called when the purchase completes.
/// This accepts a ``PurchaseResult``.
/// - Note: You only need to finish the transaction after this if you're providing a ``PurchaseController``
/// when configuring the SDK. Otherwise ``Superwall`` will handle this for you.
/// - Warning: You cannot use this function while also setting ``SuperwallOptions/shouldObservePurchases``
/// to `true`.
public func purchase(
_ product: StoreProduct,
completion: @escaping (PurchaseResult) -> Void
Expand All @@ -783,9 +814,9 @@ public final class Superwall: NSObject, ObservableObject {
}
}

/// Initiates a purchase of a `SKProduct`.
/// Initiates a purchase of a StoreKit 2 `Product`.
///
/// Use this function to purchase any `SKProduct`, regardless of whether you
/// Use this function to purchase any `Product`, regardless of whether you
/// have a paywall or not. Superwall will handle the purchase with `StoreKit`
/// and return the ``PurchaseResult``. You'll see the data associated with the
/// purchase on the Superwall dashboard.
Expand All @@ -796,6 +827,8 @@ public final class Superwall: NSObject, ObservableObject {
/// This accepts a ``PurchaseResult``.
/// - Note: You only need to finish the transaction after this if you're providing a ``PurchaseController``
/// when configuring the SDK. Otherwise ``Superwall`` will handle this for you.
/// - Warning: You cannot use this function while also setting ``SuperwallOptions/shouldObservePurchases``
/// to `true`.
@available(iOS 15.0, *)
public func purchase(
_ product: StoreKit.Product,
Expand All @@ -822,6 +855,8 @@ public final class Superwall: NSObject, ObservableObject {
/// This accepts a ``PurchaseResult``.
/// - Note: You only need to finish the transaction after this if you're providing a ``PurchaseController``
/// when configuring the SDK. Otherwise ``Superwall`` will handle this for you.
/// - Warning: You cannot use this function while also setting ``SuperwallOptions/shouldObservePurchases``
/// to `true`.
public func purchase(
_ product: SKProduct,
completion: @escaping (PurchaseResult) -> Void
Expand All @@ -847,31 +882,8 @@ public final class Superwall: NSObject, ObservableObject {
/// This accepts a ``PurchaseResult``.
/// - Note: You only need to finish the transaction after this if you're providing a ``PurchaseController``
/// when configuring the SDK. Otherwise ``Superwall`` will handle this for you.
@available(swift, obsoleted: 1.0)
@available(iOS 15.0, *)
public func purchase(
_ product: StoreKit.Product,
completion: @escaping (PurchaseResultObjc) -> Void
) {
purchase(product) { result in
let objcResult = result.toObjc()
completion(objcResult)
}
}

/// Objective-C-only method. Initiates a purchase of a `SKProduct`.
///
/// Use this function to purchase any `SKProduct`, regardless of whether you
/// have a paywall or not. Superwall will handle the purchase with `StoreKit`
/// and return the ``PurchaseResult``. You'll see the data associated with the
/// purchase on the Superwall dashboard.
///
/// - Parameters:
/// - product: The `SKProduct` you wish to purchase.
/// - completion: A completion block that is called when the purchase completes.
/// This accepts a ``PurchaseResult``.
/// - Note: You only need to finish the transaction after this if you're providing a ``PurchaseController``
/// when configuring the SDK. Otherwise ``Superwall`` will handle this for you.
/// - Warning: You cannot use this function while also setting ``SuperwallOptions/shouldObservePurchases``
/// to `true`.
@available(swift, obsoleted: 1.0)
public func purchase(
_ product: SKProduct,
Expand Down
2 changes: 1 addition & 1 deletion SuperwallKit.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SuperwallKit"
s.version = "4.0.5"
s.version = "4.0.6"
s.summary = "Superwall: In-App Paywalls Made Easy"
s.description = "Paywall infrastructure for mobile apps :) we make things like editing your paywall and running price tests as easy as clicking a few buttons. superwall.com"

Expand Down
Loading