1

I used to use Receigen to generate receipt-validation code, but since Apple has deprecated exit code 173, everything is being adapted to StoreKit2. Following a similar approach to https://developer.apple.com/documentation/storekit/apptransaction/shared (and an example provided by Apple Developer Technical Support at https://developer.apple.com/forums/thread/764537?page=2), I am basically replacing the old receipt-check with:

Swift:

@objc class ValidateReceipt: NSObject {
    @objc func validate() async -> Bool {
        do {
            let verificationResult = try await AppTransaction.shared
            
            switch verificationResult {
                case .verified(_ /*let appTransaction*/):
                    // StoreKit verified that the user purchased this app and
                    // the properties in the AppTransaction instance
                    return true;
                    
                default:
                    // The app transaction didn't pass StoreKit's verification
                    return false;
            }
        }
        catch {
            // Handle errors
            return false;
        }
    }
}

Objective-C:

    ValidateReceipt *validateReceipt = [[ValidateReceipt alloc] init];
    [validateReceipt validateWithCompletionHandler:^(BOOL result) {
        if (result)
        {
            // Successful app purchase validation
        }
        else
        {
            // App purchase validation failure
        }
    }];

Thing is, the .verified path always runs. I've tried changing users, logging out of the App Store, logging in to the App Store with a different user, building a fresh Release package and running it directly...and I always get the same verified result.

All I want to do is verify that the user is using a properly purchased version of the app — not one that someone bought and put up on an FTP server or something. The Apple documentation says "StoreKit verified that the user purchased this app", but based on testing I'm not confident that this is doing that.

Has anyone gone through this, and could possibly shed some light on what exactly it's doing? Is AppTransaction.shared doing what I want it to be doing and I'm just misunderstanding the how and why?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.