When developing in sandbox environment, I get receipt url from [[NSBundle mainBundle] appStoreReceiptURL] and post http request with it to sandbox server to validate.
But as StoreKitTest is a local test environment, this approach does not work ever more, I always receive respond with error 21002.
As mentioned in [https://developer.apple.com/documentation/xcode/setting_up_storekit_testing_in_xcode?language=objc)
But as StoreKitTest is a local test environment, this approach does not work ever more, I always receive respond with error 21002.
As mentioned in [https://developer.apple.com/documentation/xcode/setting_up_storekit_testing_in_xcode?language=objc)
I know I should install the StoreKitTestCertificate.cer file for my test device, but how to use the code above in my project, and how to retrieve the receipt from the local. Is there any sample code available?Be sure your code uses the correct certificate in all environments. Add the following conditional compilation block to select the test certificate for testing, and the Apple root certificate otherwise.
#if DEBUG
let certificate = “StoreKitTestCertificate”
#else
let certificate = “AppleIncRootCertificate”
#endif
You can fetch the receipt using the same API you mentioned: [[NSBundle mainBundle] appStoreReceiptURL]. The certificate is to be used for local receipt validation as the verify receipt endpoint for server-to-server validation isn't supported. More in-depth documentation is available here.