TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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

Forums > SwiftUI

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.

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() {

        }
    }

}

2      

Did you solve this??

   

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.