diff --git a/CHANGELOG.md b/CHANGELOG.md index f9a35cf53..c6385683c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,14 @@ The changelog for `SuperwallKit`. Also see the [releases](https://github.com/sup - Changes Objective-C method `getTrackInfo` to `getTrackResult` to be in line with the Swift API. - Removes the error case from the `TrackResult` and adds in `userIsSubscribed` and `paywallNotAvailable` cases. +- Moves main actor conformance to functions of PurchaseController protocol rather than the whole protocol. +- Changes Objective-C method `setUserAttributesDictionary(_:)` to `setUserAttributes(_:)`. ### Fixes - Makes `NetworkEnvironment` Objective-C compatible. - Fixes an issue where a manually dismissed modally presented paywall wouldn't properly dismiss. +- Fixes race condition when calling identify and tracking a paywall. ## 3.0.0-beta.6 diff --git a/Examples/UIKit-ObjC/Superwall-UIKit-ObjC/Services/SSASuperwallService.m b/Examples/UIKit-ObjC/Superwall-UIKit-ObjC/Services/SSASuperwallService.m index 6cb12bba8..20b7bd809 100644 --- a/Examples/UIKit-ObjC/Superwall-UIKit-ObjC/Services/SSASuperwallService.m +++ b/Examples/UIKit-ObjC/Superwall-UIKit-ObjC/Services/SSASuperwallService.m @@ -91,7 +91,7 @@ - (nullable NSString *)name { - (void)setName:(nullable NSString *)name { id userAttributeFirstName = name ? : [NSNull null]; - [[Superwall sharedInstance] setUserAttributesDictionary:@{ kUserAttributesFirstNameKey : userAttributeFirstName }]; + [[Superwall sharedInstance] setUserAttributes:@{ kUserAttributesFirstNameKey : userAttributeFirstName }]; } #pragma mark - Public Methods diff --git a/Sources/SuperwallKit/Delegate/Subscription Controller/PurchaseController.swift b/Sources/SuperwallKit/Delegate/Subscription Controller/PurchaseController.swift index d3465b937..e19d0f807 100644 --- a/Sources/SuperwallKit/Delegate/Subscription Controller/PurchaseController.swift +++ b/Sources/SuperwallKit/Delegate/Subscription Controller/PurchaseController.swift @@ -20,7 +20,6 @@ import StoreKit /// /// To learn how to implement the ``PurchaseController`` in your app /// and best practices, see . -@MainActor public protocol PurchaseController: AnyObject { /// Called when the user initiates purchasing of a product. /// @@ -31,6 +30,7 @@ public protocol PurchaseController: AnyObject { /// /// - Returns: A``PurchaseResult`` object, which is the result of your purchase logic. /// **Note**: Make sure you handle all cases of ``PurchaseResult``. + @MainActor func purchase(product: SKProduct) async -> PurchaseResult /// Called when the user initiates a restore. @@ -39,5 +39,6 @@ public protocol PurchaseController: AnyObject { /// and return its result. /// /// - Returns: A boolean that's `true` if the user's purchases were restored or `false` if they weren't. + @MainActor func restorePurchases() async -> Bool } diff --git a/Sources/SuperwallKit/Delegate/Subscription Controller/PurchaseControllerObjc.swift b/Sources/SuperwallKit/Delegate/Subscription Controller/PurchaseControllerObjc.swift index 8ecc61c2a..982787862 100644 --- a/Sources/SuperwallKit/Delegate/Subscription Controller/PurchaseControllerObjc.swift +++ b/Sources/SuperwallKit/Delegate/Subscription Controller/PurchaseControllerObjc.swift @@ -20,7 +20,6 @@ import StoreKit /// /// To learn how to implement the ``PurchaseControllerObjc`` in your app /// and best practices, see . -@MainActor @objc(SWKPurchaseController) public protocol PurchaseControllerObjc: AnyObject { /// Called when the user initiates purchasing of a product. @@ -33,6 +32,7 @@ public protocol PurchaseControllerObjc: AnyObject { /// Call this with the result of your purchase logic. When you pass a `.failed` result, make sure you also pass /// the error. /// **Note:** Make sure you handle all cases of ``PurchaseResult``. + @MainActor @objc func purchase( product: SKProduct, completion: @escaping (PurchaseResultObjc, Error?) -> Void @@ -45,5 +45,6 @@ public protocol PurchaseControllerObjc: AnyObject { /// /// - Parameters: /// - completion: Call the completion with `true` if the user's purchases were restored or `false` if they weren't. + @MainActor @objc func restorePurchases(completion: @escaping (Bool) -> Void) } diff --git a/Sources/SuperwallKit/Documentation.docc/Extensions/SuperwallExtension.md b/Sources/SuperwallKit/Documentation.docc/Extensions/SuperwallExtension.md index e8db7bbfc..7354f6818 100644 --- a/Sources/SuperwallKit/Documentation.docc/Extensions/SuperwallExtension.md +++ b/Sources/SuperwallKit/Documentation.docc/Extensions/SuperwallExtension.md @@ -41,6 +41,7 @@ The ``Superwall`` class is used to access all the features of the SDK. Before us - ``getTrackResult(forEvent:params:)-1qexk`` - ``getTrackResult(forEvent:params:completion:)`` - ``getTrackResult(forEvent:params:)-2j7qn`` +- ``getTrackResult(forEvent:)`` - ``dismiss()-844a9`` - ``dismiss()-4objm`` - ``dismiss(completion:)`` @@ -64,8 +65,8 @@ The ``Superwall`` class is used to access all the features of the SDK. Before us - ``identify(userId:)`` - ``IdentityOptions`` - ``reset()`` -- ``setUserAttributes(_:)`` -- ``setUserAttributesDictionary(_:)`` +- ``setUserAttributes(_:)-1wql2`` +- ``setUserAttributes(_:)-8jken`` - ``removeUserAttributes(_:)`` - ``userAttributes`` diff --git a/Sources/SuperwallKit/Documentation.docc/SettingUserAttributes.md b/Sources/SuperwallKit/Documentation.docc/SettingUserAttributes.md index 0b337ab36..69aa82311 100644 --- a/Sources/SuperwallKit/Documentation.docc/SettingUserAttributes.md +++ b/Sources/SuperwallKit/Documentation.docc/SettingUserAttributes.md @@ -6,7 +6,7 @@ Set user attributes for use in your paywalls and the dashboard. You can display information about the user on the paywall by setting user attributes. -You do this by passing a `[String: Any?]` dictionary of attributes to ``Superwall/setUserAttributes(_:)``: +You do this by passing a `[String: Any?]` dictionary of attributes to ``Superwall/setUserAttributes(_:)-1wql2``: ```swift extension SuperwallService { diff --git a/Sources/SuperwallKit/Identity/UserAttributes.swift b/Sources/SuperwallKit/Identity/UserAttributes.swift index a7b819bcc..8f24eaa04 100644 --- a/Sources/SuperwallKit/Identity/UserAttributes.swift +++ b/Sources/SuperwallKit/Identity/UserAttributes.swift @@ -47,7 +47,7 @@ extension Superwall { /// /// ``` /// NSDictionary *userAttributes = @{ key : value, key2 : value2}; - /// [[Superwall sharedInstance] setUserAttributesDictionary: userAttributes]; + /// [[Superwall sharedInstance] setUserAttributes:userAttributes]; /// ``` /// /// - Parameters: @@ -56,7 +56,7 @@ extension Superwall { /// Note: Keys beginning with `$` are reserved for Superwall and will be dropped. Arrays and dictionaries /// as values are not supported at this time, and will be dropped. @available(swift, obsoleted: 1.0) - @objc public func setUserAttributesDictionary(_ attributes: NSDictionary) { + @objc public func setUserAttributes(_ attributes: NSDictionary) { var swiftDictionary: [String: Any?] = [:] let keys = attributes.allKeys.compactMap { $0 as? String } for key in keys { diff --git a/Sources/SuperwallKit/Paywall/Presentation/PublicPresentation.swift b/Sources/SuperwallKit/Paywall/Presentation/PublicPresentation.swift index 700761103..db7da23f9 100644 --- a/Sources/SuperwallKit/Paywall/Presentation/PublicPresentation.swift +++ b/Sources/SuperwallKit/Paywall/Presentation/PublicPresentation.swift @@ -55,7 +55,7 @@ extension Superwall { // MARK: - Objective-C-only Track /// An Objective-C-only method that shows a paywall to the user when: An event you provide is tied to an /// active trigger inside a campaign on the [Superwall Dashboard](https://superwall.com/dashboard); - /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)`` + /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)-1wql2`` /// if you’re using Swift. /// /// Triggers enable you to retroactively decide where or when to show a specific paywall in your app. Use this method @@ -215,7 +215,7 @@ extension Superwall { /// An Objective-C-only method that shows a paywall to the user when: An event you provide is tied to an /// active trigger inside a campaign on the [Superwall Dashboard](https://superwall.com/dashboard); - /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)`` + /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)-1wql2`` /// if you’re using Swift. /// /// Triggers enable you to retroactively decide where or when to show a specific paywall in your app. Use this method @@ -239,7 +239,7 @@ extension Superwall { /// An Objective-C-only method that shows a paywall to the user when: An event you provide is tied to an /// active trigger inside a campaign on the [Superwall Dashboard](https://superwall.com/dashboard); - /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)`` + /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)-1wql2`` /// if you’re using Swift. /// /// Triggers enable you to retroactively decide where or when to show a specific paywall in your app. Use this method @@ -269,7 +269,7 @@ extension Superwall { /// An Objective-C-only method that shows a paywall to the user when: An event you provide is tied to an /// active trigger inside a campaign on the [Superwall Dashboard](https://superwall.com/dashboard); - /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)`` + /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)-1wql2`` /// if you’re using Swift. /// /// Triggers enable you to retroactively decide where or when to show a specific paywall in your app. Use this method @@ -310,7 +310,7 @@ extension Superwall { /// An Objective-C-only method that shows a paywall to the user when: An event you provide is tied to an /// active trigger inside a campaign on the [Superwall Dashboard](https://superwall.com/dashboard); - /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)`` + /// and the user matches a rule in the campaign. **Note**: Please use ``Superwall/setUserAttributes(_:)-1wql2`` /// if you’re using Swift. /// /// Triggers enable you to retroactively decide where or when to show a specific paywall in your app. Use this method diff --git a/Sources/SuperwallKit/Superwall.swift b/Sources/SuperwallKit/Superwall.swift index e74b0725a..ac87155d9 100644 --- a/Sources/SuperwallKit/Superwall.swift +++ b/Sources/SuperwallKit/Superwall.swift @@ -42,7 +42,7 @@ public final class Superwall: NSObject, ObservableObject { } } - /// Properties stored about the user, set using ``setUserAttributes(_:)``. + /// Properties stored about the user, set using ``setUserAttributes(_:)-1wql2``. public var userAttributes: [String: Any] { return dependencyContainer.identityManager.userAttributes }