I'm a bit new to coding and to Revenue Cat. I just want to make sure this will work before transitioning from sandbox to production, since there's no way to test it in sandbox.
Purchases.shared.restoreTransactions { (purchaserInfo, error) in
let originalPurchaseDate = purchaserInfo?.originalPurchaseDate
let formatter = DateFormatter()
formatter.dateFormat = "yyyy/MM/dd HH:mm"
let switchOverDate = formatter.date(from: "2020/06/29 00:00")
if originalPurchaseDate! < switchOverDate! {
// unlock all content
}
}
Will this let me grandfather in my old users (who paid for my app) when I switch to subscription?
Thank you!
You'll actually want to check the original application version here. This is available on the RevenueCat iOS SDK and will be the CFBundleVersion
of the original app version the user downloaded.
Purchases.shared.restoreTransactions { (purchaserInfo, error) in
// Make sure there weren't any errors...
if let originalApplicationVersion = purchaserInfo?.originalApplicationVersion {
if originalApplicationVersion < "your_build_number_string" {
// Legacy user! Unlock content
}
}
// Check if user restored another purchase...
}
Important:
Remember the CFBundleVersion is the build number, not the app version. Also:
In the sandbox environment, the value of this field is always “1.0”.