Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAT-1726: Support Deferring Win-Back StoreKit Messages #4343

Merged
merged 14 commits into from
Oct 7, 2024

Conversation

fire-at-will
Copy link
Contributor

@fire-at-will fire-at-will commented Oct 2, 2024

Motivation

iOS 18 introduces win-back offers to allow developers to extend offers to churned subscribers. In iOS 18+, StoreKit sends apps a StoreKit Message when a subscriber is eligible to redeem a win-back offer. We currently support showing this message automatically if the showStoreMessagesAutomatically configuration option is true, but don't yet support deferring displaying the message.

Description

This PR adds win-back offers to the StoreMessageType enum so that we can support deferring StoreKit Messages where the reason is winBackOffer.

Xcode Compatibility Issues

StoreKit.Message.Reason.winBackOffer is available on iOS 18.0+ and wasn't back ported to be available in Xcode versions <16.0. Thus, if we reference StoreKit.Message.Reason.winBackOffer without checking for the Xcode version, we'll break compilation on all versions of Xcode less than 16.0:

Screenshot 2024-10-02 at 1 13 04 PM

Building the SDK when referencing StoreKit.Message.Reason.winBackOffer in Xcode 15.4 for a simulator running iOS 18.1 results in a build failure

Since Swift doesn't provide a way to do conditional compilation based on Xcode version, our next best option is to check the Swift compiler version, since the Swift compiler version is tied to Xcode versions. Since the Swift 6 compiler shipped with Xcode 16, this PR makes our handling of deferred win-back offer messages dependent on the Swift compiler version being >=6.0.

Testing

  • The changes were tested manually.

@fire-at-will fire-at-will added the pr:feat A new feature label Oct 2, 2024
@fire-at-will fire-at-will changed the title CAT-1726: Support Deferring Win-Back StoreKit Messages CAT-1726: Support Deferring Win-Back StoreKit Messages For Apps Using Swift >= 6.0 Oct 2, 2024
@@ -40,6 +47,14 @@ extension Message.Reason {
case .priceIncreaseConsent: return .priceIncreaseConsent
case .generic: return .generic
default:
// winBackOffer message reason was added in iOS 18.0, but it's not recognized by xcode versions <16.0.
// https://developer.apple.com/documentation/xcode-release-notes/xcode-14_3-release-notes
#if swift(>=6.0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the PR description for more details on why this is necessary

Copy link
Member

@MarkVillacampa MarkVillacampa Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the swift compilation condition defines the swift mode, whereas compiler refers to the swift compiler version.

A lot of people will compile in Swift 5.X mode while using Xcode. Since what we actually want to do is detect the Xcode version, and Xcode 16 comes with the Swift 6.0 compiler, it's better to use the compiler condition instead of swift, as we know if ties directly the Xcode version.

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/statements/#Conditional-Compilation-Block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah, TIL! Will switch to using the compiler condition. Thank you!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched in to using the compiler condition in 086dce6 😎

@fire-at-will fire-at-will marked this pull request as ready for review October 2, 2024 18:19
@fire-at-will fire-at-will self-assigned this Oct 2, 2024
@fire-at-will fire-at-will changed the title CAT-1726: Support Deferring Win-Back StoreKit Messages For Apps Using Swift >= 6.0 CAT-1726: Support Deferring Win-Back StoreKit Messages Oct 2, 2024
Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@fire-at-will fire-at-will added the feat:Win-Back Offers Supporting iOS 18's Win-Back Offers label Oct 3, 2024
@fire-at-will fire-at-will merged commit c814d0e into main Oct 7, 2024
7 checks passed
@fire-at-will fire-at-will deleted the CAT-1726_support_deferring_winback_sk_messages branch October 7, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat:Win-Back Offers Supporting iOS 18's Win-Back Offers pr:feat A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants