In app purchase Storekit SwiftUI button grayed out after purchase is complete in iOS 17


I’m testing In App Purchase for my iOS app using iOS 17 with SwiftUI.

After successfully making a purchase the buy button is grayed out. This way I cannot test the purchase again. I even deleted the app and reinstalled it, but the button is still grayed out, like shown in the picture below.

enter image description here

This is the code I’m using. How do I enable the purchase button again?

import SwiftUI
import StoreKit

struct InAppPurchaseDetailView: View {
    var item:InAppItems
    
    var body: some View {
        
        NavigationStack {
            
            VStack {
                ProductView(id: item.identifier) {
                    Image(iconName)
                        .resizable()
                             .aspectRatio(contentMode: .fit)
                             .frame(maxWidth: 120, maxHeight: 120)
                             .cornerRadius(10)
                }
                .productViewStyle(.large)
                .padding()
                .onInAppPurchaseStart { product in
                    print("User has started buying \(product.id)")
                }
                .onInAppPurchaseCompletion { product, result in
                    if case .success(.success(let transaction)) = result {
                        print("Purchased successfully: \(transaction.signedDate)")
                    } else {
                        print("Something else happened")
                    }
                }
            }
        }             
        .onAppear() {
            
        }
    }
    
}

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img