收益猫——老用户中的爷爷

Revenue Cat - grandfather in old users

我对编码和 Revenue Cat 有点陌生。我只是想确保它在从沙箱过渡到生产之前能够正常工作,因为无法在沙箱中对其进行测试。

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
        }
}

当我切换到订阅时,这会让我在我的老用户(为我的应用程序付费)中成为祖父吗?

谢谢!

您实际上需要在此处查看原始应用程序版本。这在 RevenueCat iOS SDK 上可用,并且将是用户下载的原始应用程序版本的 CFBundleVersion

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...
}

重要提示:

请记住 CFBundleVersion 是 build 编号,而不是应用程序版本。还有:

In the sandbox environment, the value of this field is always “1.0”.

Source: https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html