I’m trying to change my business model within the app, and following Apple’s documentation guidelines HERE I created this task in the main view of the app. It seems to work perfectly in the simulator, on physical devices, and on TestFlight. However, after releasing it to production and uploading the new version to the App Store, it doesn’t work, and all users, whether new or existing, are asked to subscribe. In the console, it appears to retrieve the transactions correctly, but in production, I’m not sure how to view the console or see what it’s retrieving.
Here the sandbox receipt I obtained
AppTransaction.shared obtained: {
"applicationVersion" : "1",
"bundleId" : *****
"deviceVerification" : "6M0Nnw14nSEOBVTPE\/\/EfnWSwLm7LFSlrpFEwxgH74SBHp5dSzBEm896Uvo42mwr",
"deviceVerificationNonce" : "8a8238c0-0aee-41e6-bfb0-1cfc52b70fb6",
"originalApplicationVersion" : "1.0",
"originalPurchaseDate" : 1375340400000,
"receiptCreationDate" : 1737577840917,
"receiptType" : "Sandbox",
"requestDate" : 1737577840917
}
This are the processing log while verified the receipt
New business model change: 1.7
Original versionéis components: ["1", "0"]
Major version: 1, Minor version: 0
This user is premium. Original version: 1.0
This is my task...
.task {
do {
let shared = try await AppTransaction.shared
if case .verified(let appTransaction) = shared {
let newBusinessModelVersion = (1, 7) // Representado como (major, minor)
let versionComponents = appTransaction.originalAppVersion.split(separator: ".")
if let majorVersion = versionComponents.first.flatMap({ Int($0) }),
let minorVersion = versionComponents.dropFirst().first.flatMap({ Int($0) }) {
if (majorVersion, minorVersion) < newBusinessModelVersion {
self.premiumStatus.isPremium = true
isPremium = true
} else {
let customerInfo = try await Purchases.shared.customerInfo()
self.premiumStatus.isPremium = customerInfo.entitlements["premium"]?.isActive == true
isPremium = self.premiumStatus.isPremium
}
} else {
print("Error: obteining version components")
}
} else {
print("Not verified")
}
} catch {
print("Error processing transaction: \(error.localizedDescription)")
}
}
It sounds like the issue might be related to how the CFBundleVersion
is defined in your app. If you’re using a build number (e.g., an incremental count of commits) for CFBundleVersion
instead of the app’s version number (e.g., major.minor.patch), this could cause problems in production.
Apple’s documentation for the originalAppVersion
states:
The originalAppVersion [...] contains the original value of the CFBundleShortVersionString for apps running on macOS, and the original value of the CFBundleVersion for apps running on all other platforms.
In the sandbox testing environment, the originalAppVersion value is always 1.0.
This behavior explains why everything works correctly in testing environments (simulator, physical devices, and TestFlight) where originalAppVersion
defaults to 1.0. However, in production, the value of CFBundleVersion
is used, and if it doesn’t match the expected format, it could lead to issues with determining whether a user is new or existing.
To address this, ensure that CFBundleVersion
contains the app's version number (major.minor.patch) for production builds, or update your logic to account for your current use of build numbers.