I am trying to implement offer codes in my SwiftUI app to provided a discounted first month of a subscription. But when I attempt to input the code in the redemption sheet it tells me it can't find the code.
Here is where I call the sheet:
var body: some View {
ScrollView(showsIndicators: false) {
codeRedemptionButton
Link(destination: URL(string: ";id=6737702561&code=TEST2")!, label: {
Text("Redemption Link")
})
}
.offerCodeRedemption(isPresented: $showCodeRepemptionSheet) { result in
switch result {
case .success(let code):
print("Offer code redeemed: \(code)")
case .failure(let error):
print("Offer code redemption failed: \(error)")
}
}
}
private var codeRedemptionButton: some View {
Button(action: {
// Call the redemption sheet
showCodeRepemptionSheet = true
}, label: {
Text("Have a code? Redeem it here.")
})
}
and here are my codes in App Store Connect
The sheet shows up properly but does not find codes that already exist and show up in my StoreKitConfiguration file. Also the Link works properly so that should mean that the codes were established properly. Can someone explain what I am doing wrong and how to properly implement offer codes with an swiftUI app?
EDIT: Updated code to use modern SwiftUI calling of the redemption sheet and renamed the question to fit the new code. Also added information about using Link vs Redemption sheet.