Skip to content
Merged
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The changelog for `SuperwallKit`. Also see the [releases](https://github.com/sup
- Makes `device.isSandbox` more reliable.
- Fixes the web restore alert not showing the "Yes" action button and "Cancel" incorrectly triggering the restore action.
- Fixes a rare issue where a user's subscription could remain active after a refund, preventing paywalls from being shown.
- Fixes trial eligibility for Stripe products.
- Fixes trial eligibility for Stripe paywalls and tracks `freeTrial_start`.
- Fixes an issue where `transaction_complete` could be missing transaction information when a crossgrade occurred while using a purchase controller.
- Fixes terminated webviews refreshing in a loop on low RAM devices.

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 23 additions & 11 deletions Sources/SuperwallKit/Web/WebEntitlementRedeemer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ actor WebEntitlementRedeemer {
let event = InternalSuperwallEvent.Transaction(
state: .abandon(product),
paywallInfo: paywallInfo,
product: nil,
product: product,
transaction: nil,
source: .internal,
isObserved: false,
Expand Down Expand Up @@ -561,20 +561,32 @@ actor WebEntitlementRedeemer {
await self.delegate.didRedeemLink(result: codeResult)
}

// Schedule free trial notification if applicable
// Track free trial start and schedule notification if applicable
if case .success(_, let redemptionInfo) = codeResult,
let product = redemptionInfo.paywallInfo?.product,
product.trialPeriodDays > 0,
let redemptionProduct = redemptionInfo.paywallInfo?.product,
redemptionProduct.trialPeriodDays > 0,
let paywallVc = superwall.paywallViewController {
let paywallInfo = await paywallVc.info
let notifications = paywallInfo.localNotifications.filter {
$0.type == .trialStarted
if paywallInfo.isFreeTrialAvailable {
let product = StoreProduct.blank(
productIdentifier: redemptionProduct.identifier
)
await superwall.track(
InternalSuperwallEvent.FreeTrialStart(
paywallInfo: paywallInfo,
product: product,
transaction: nil
)
)
let notifications = paywallInfo.localNotifications.filter {
$0.type == .trialStarted
}
await self.notificationScheduler.scheduleNotifications(
notifications,
fromPaywallId: paywallInfo.identifier,
factory: self.factory
)
}
await self.notificationScheduler.scheduleNotifications(
notifications,
fromPaywallId: paywallInfo.identifier,
factory: self.factory
)
}

if let paywallVc = superwall.paywallViewController,
Expand Down
Loading
Loading