What's new in StoreKit testing

RSS for tag

Discuss the WWDC22 Session What's new in StoreKit testing

Posts under wwdc2022-10039 tag

10 Posts

Post

Replies

Boosts

Views

Activity

StoreKit2: using AppTransaction.shared triggers user login
Hi, I plan to use the new AppTransaction.shared API in StoreKit2 to find the user's original purchase date and version for my macOS app. However, when testing this running in the debugger, the app shows up with an App Store login prompt, asking for my login and password, which is undesirable. I wanted to know if this is just a sandbox quirk, or is the "AppTransaction.shared" API supposed to trigger this prompt for all users, even in production? In that case, is it like the old "Refresh receipt" API where we shouldn't trigger this automatically when a user opens the app, and instead have a button somewhere that triggers the call? Thanks.
1
0
875
Mar ’23
StoreKit 2, existing Non-Renewing Subscription but user not logged to App Store on device
Hi, I am testing an implementation of a non renewing subscription. State: A user has an existing entitlement, and moves to a new device on which the user is not logged into the App Store. Problem: User not logged in -> currentEntitlements not available. User, in error, presses purchase instead of restore (user is informed with small note.) StoreKit 2 will warn the user that he has already purchased this in the past and will allow the user to buy again. (App Store Connect does not store non renewing subscription duration, so I can understand store kit behaviour) Question: Can I check if user is not signed into the App Store? then force a call sync prior to purchase. OR Should I just leave this tiny fringe case to Apple support to issue refunds for user error (dual subscriptions)?
0
0
655
Feb ’23
SKAdTestSession Error
Hello, I Have bug while testing SKAdTestSession below error occurred when call SKAdTestSession.setPostbacks and SKAdTestSession.updatePostbackConversionValue. How can I fix it?? Xcode : Version 14.0 (14A309) Test Device : Version 14.0 (986.3), SimulatorKit 624, CoreSimulator 857.7, iPhone 13 Pro, iOS 16.0 <NSXPCConnection: 0x600000b20320> connection from pid 16227 on mach service named com.apple.storekit.configuration.xpc: Warning: Exception caught during invocation of selector sendTestPingbackForBundleID:completion:, dropping incoming message and invalidating the connection. Exception: -[StoreKitTestingService sendTestPingbackForBundleID:completion:]: unrecognized selector sent to instance 0x600003824150 -[StoreKitTestingService sendTestPingbackForBundleID:completion:]: unrecognized selector sent to instance 0x600003824150 ( 0   CoreFoundation                      0x000000018040c304 __exceptionPreprocess + 172 1   libobjc.A.dylib                     0x000000018005131c objc_exception_throw + 56 2   CoreFoundation                      0x000000018041afbc +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0 3   CoreFoundation                      0x000000018040ffcc ___forwarding___ + 740 4   CoreFoundation                      0x000000018041268c _CF_forwarding_prep_0 + 92 5   Foundation                          0x0000000180cadca4 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT_S2__ + 12 6   Foundation                          0x0000000180cac9e0 -[NSXPCConnection _decodeAndInvokeMessageWithEvent:reply:flags:] + 1588 7   Foundation                          0x0000000180caeab0 message_handler_message + 84 8   Foundation                          0x0000000180cae03c message_handler + 148 9   libxpc.dylib                        0x0000000180088404 _xpc_connection_call_event_handler + 68 10  libxpc.dylib                        0x00000001800887c4 _xpc_connection_mach_event + 904 11  libdispatch.dylib                   0x000000018013581c _dispatch_client_callout4 + 16 12  libdispatch.dylib                   0x0000000180153f20 _dispatch_mach_msg_invoke + 624 13  libdispatch.dylib                   0x000000018013d648 _dispatch_lane_serial_drain + 348 14  libdispatch.dylib                   0x0000000180154fec _dispatch_mach_invoke + 468 15  libdispatch.dylib                   0x000000018013d648 _dispatch_lane_serial_drain + 348 16  libdispatch.dylib                   0x000000018013e474 _dispatch_lane_invoke + 448 17  libdispatch.dylib                   0x000000018014a624 _dispatch_workloop_worker_thread + 772 18  libsystem_pthread.dylib             0x00000001ae55eb40 _pthread_wqthread + 284 19  libsystem_pthread.dylib             0x00000001ae55d904 start_wqthread + 8 )
0
0
865
Dec ’22
StoreKit2: save currentEntitlements in keychain
Hi, With StoreKit2 giving us the up-to-date subscription status using Transaction.currentEntitlements, is there any value in storing the status separately in keychain as well? Or will that just add an unnecessary layer to manage (and possibly mess up)? I just want to subscription status to know if I need to unlock certain features in the app or not, and wondering if just looking at currentEntitlements and saving that in my Store object is enough. Thanks.
1
0
889
Oct ’22
StoreKit 2 - Issue
Hello, Im trying to use in-app purchases for first time. I have followed the tutorial for StoreKit 2 from the WWDC21 and in the simulator with the StoreKit Configuration File all was OK. But now I want test to the real server and I have this response: Error enumerating unfinished transactions for first transaction listener: Error Domain=ASDErrorDomain Code=509 "No active account" UserInfo={client-environment-type=Sandbox, storefront-country-code=USA, NSLocalizedDescription=No active account} In "Run" -> "StoreKit configuration" I have selected none In AppleStoreConnect I have created the auto-renewal suscription like in my StoreKit configuration. Also I create a new StoreKit configuration from the AppleStoreConnect and with this file its OK too. None of my testflight testers can see the options to purchase. I dont create any sandbox user. It's the problem? I saw in the documentation thats not needed. I am thankful for any kind of help. David
2
1
3.1k
Oct ’22
StoreKit 2: `try await Product.products` does not finish and does not throw. Can watchOS fetch products on TestFlight builds? iOS works
I am using a class that targets both my iOS as well as my watchOS target - so both use the same code. If I upload my code to TestFlight, my iPhone is able to fetch the products just fine. However, with my Apple Watch, the process seems to stall. I have implemented a log stream so that I can gather log output in TestFlight builds (where Xcode is not attached). This is my code: do { log("1") // reaches statement on iPhone, reaches statement on Watch let storeProducts = try await Product.products(for: productIDs) log("2") // reaches statement on iPhone, DOES NOT reach statement on Watch } catch { log("3") // does not get called on Watch either } Now unless I misinterpret the log statements, it looks like try await Product.products(for: productIDs) neither returns, nor throws. I have kept open my ViewController for minutes but there is no progress. My situation right now is the following: I have an app live that employs SwiftyStoreKit. This however breaks on iOS 16 so we are now moving over to StoreKit (2) for iOS 16 and watchOS 9 devices (older versions will stay on SwiftyStoreKit). Publishing a release without verifying in TestFlight is very risky so I am hoping someone can confirm that this is an issue with StoreKit 2 that TestFlight versions cannot fetch products in watchOS. However I cannot find any information from Apple or in any forum on this. We have also tried implementing the purchases via RevenueCat which also threw some weird errors (like this one https://community.revenuecat.com/sdks-51/receipt-is-missing-when-trying-to-purchase-via-testflight-1491) especially on watchOS. The Sandbox and TestFlight environments are known to be very buggy but it's a huge risk now to push an update without being able to confirm that it actually works at least once. Weirdly enough, with SwiftyStoreKit I can still see all my purchases in TestFlight which makes me think that the issue is on StoreKit 2's side - as SwiftyStoreKit still uses StoreKit 1 but without any other information on this that's purely speculation. So I'm hoping someone has ran into the same issue and knows more than I do.
1
0
1.4k
Sep ’22
StoreKit 2 in-app purchase restore
Apps that support in-app purchases are rejected in App Review unless they implement the ability to restore previous purchases. There is a WWDC 2022 video on doing exactly that and I am doing what that video suggests, but my app is still rejected. Here's what they say: "When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code "Sandbox receipt used in production," you should validate against the test environment instead." To which I replied: "I don’t have a server. Can you explain what “your server” means for an iOS app that has no server-side components?" But they won't explain themselves. They just say: "Your question requires technical assistance and would be best addressed by Apple Developer Technical Support who can provide discrete code-level assistance for Apple frameworks, APIs, and tools." Can someone point me to a code example that shows how to do this? My failed attempt is here: https://github.com/mvolkmann/SwiftUI-GiftTrack/blob/main/GiftTrack/ViewModels/StoreViewModel.swift
2
0
4.2k
Sep ’22
While trying to purchase from sandbox its showing me that error in Xcode 13 and iOS 14.3
<SKPaymentQueue: 0x282526050>: Payment completed with error: Error Domain=ASDErrorDomain Code=500 "Unhandled exception" UserInfo={NSUnderlyingError=0x28280aee0 {Error Domain=AMSErrorDomain Code=301 "Invalid Status Code" UserInfo={NSLocalizedDescription=Invalid Status Code, NSLocalizedFailureReason=The response has an invalid status code}}, NSLocalizedFailureReason=An unknown error occurred, NSLocalizedDescription=Unhandled exception}
0
0
916
Jul ’22
Strange runtime error when using StoreKit Test API
We are trying to integrate StoreKit Testing into our unit and UI testing flow on Mac and iOS. The basic idea is bypassing the paywall so that the specific test can do its job without interference. In our subclass of XCUIApplication, we've overridden the launch method to simulate the purchase of the app's full version: import XCTest import StoreKitTest class OurCustomApp : XCUIApplication { private var _storeKitSession : AnyObject? = nil override func launch() { super.launch() do { _storeKitSession = try SKTestSession(configurationFileNamed: "iap_desktop") (_storeKitSession as! SKTestSession).disableDialogs = true (_storeKitSession as! SKTestSession).clearTransactions() try (_storeKitSession as! SKTestSession).buyProduct(productIdentifier: "<our product identifier>") } catch { XCTFail("Can't setup StoreKit test. \(error)") } } } However, we faced a weird runtime issue: UITests-Runner[53387:25779369] Error in XPC connection when checking Xcode Test app: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.storekitagent was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.storekitagent was invalidated: failed at lookup with error 159 - Sandbox restriction.} We use the proper certificate for StoreKit Testing and follow all the steps from Setting Up StoreKit Testing in Xcode. The problem reproduces on all our machines, including Intel-based and M1 Macs. We'd appreciate any hints or clues that will help us resolve this issue.
1
0
1.7k
Jun ’22
StoreKit2: using AppTransaction.shared triggers user login
Hi, I plan to use the new AppTransaction.shared API in StoreKit2 to find the user's original purchase date and version for my macOS app. However, when testing this running in the debugger, the app shows up with an App Store login prompt, asking for my login and password, which is undesirable. I wanted to know if this is just a sandbox quirk, or is the "AppTransaction.shared" API supposed to trigger this prompt for all users, even in production? In that case, is it like the old "Refresh receipt" API where we shouldn't trigger this automatically when a user opens the app, and instead have a button somewhere that triggers the call? Thanks.
Replies
1
Boosts
0
Views
875
Activity
Mar ’23
StoreKit 2, existing Non-Renewing Subscription but user not logged to App Store on device
Hi, I am testing an implementation of a non renewing subscription. State: A user has an existing entitlement, and moves to a new device on which the user is not logged into the App Store. Problem: User not logged in -> currentEntitlements not available. User, in error, presses purchase instead of restore (user is informed with small note.) StoreKit 2 will warn the user that he has already purchased this in the past and will allow the user to buy again. (App Store Connect does not store non renewing subscription duration, so I can understand store kit behaviour) Question: Can I check if user is not signed into the App Store? then force a call sync prior to purchase. OR Should I just leave this tiny fringe case to Apple support to issue refunds for user error (dual subscriptions)?
Replies
0
Boosts
0
Views
655
Activity
Feb ’23
SKAdTestSession Error
Hello, I Have bug while testing SKAdTestSession below error occurred when call SKAdTestSession.setPostbacks and SKAdTestSession.updatePostbackConversionValue. How can I fix it?? Xcode : Version 14.0 (14A309) Test Device : Version 14.0 (986.3), SimulatorKit 624, CoreSimulator 857.7, iPhone 13 Pro, iOS 16.0 <NSXPCConnection: 0x600000b20320> connection from pid 16227 on mach service named com.apple.storekit.configuration.xpc: Warning: Exception caught during invocation of selector sendTestPingbackForBundleID:completion:, dropping incoming message and invalidating the connection. Exception: -[StoreKitTestingService sendTestPingbackForBundleID:completion:]: unrecognized selector sent to instance 0x600003824150 -[StoreKitTestingService sendTestPingbackForBundleID:completion:]: unrecognized selector sent to instance 0x600003824150 ( 0   CoreFoundation                      0x000000018040c304 __exceptionPreprocess + 172 1   libobjc.A.dylib                     0x000000018005131c objc_exception_throw + 56 2   CoreFoundation                      0x000000018041afbc +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0 3   CoreFoundation                      0x000000018040ffcc ___forwarding___ + 740 4   CoreFoundation                      0x000000018041268c _CF_forwarding_prep_0 + 92 5   Foundation                          0x0000000180cadca4 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT_S2__ + 12 6   Foundation                          0x0000000180cac9e0 -[NSXPCConnection _decodeAndInvokeMessageWithEvent:reply:flags:] + 1588 7   Foundation                          0x0000000180caeab0 message_handler_message + 84 8   Foundation                          0x0000000180cae03c message_handler + 148 9   libxpc.dylib                        0x0000000180088404 _xpc_connection_call_event_handler + 68 10  libxpc.dylib                        0x00000001800887c4 _xpc_connection_mach_event + 904 11  libdispatch.dylib                   0x000000018013581c _dispatch_client_callout4 + 16 12  libdispatch.dylib                   0x0000000180153f20 _dispatch_mach_msg_invoke + 624 13  libdispatch.dylib                   0x000000018013d648 _dispatch_lane_serial_drain + 348 14  libdispatch.dylib                   0x0000000180154fec _dispatch_mach_invoke + 468 15  libdispatch.dylib                   0x000000018013d648 _dispatch_lane_serial_drain + 348 16  libdispatch.dylib                   0x000000018013e474 _dispatch_lane_invoke + 448 17  libdispatch.dylib                   0x000000018014a624 _dispatch_workloop_worker_thread + 772 18  libsystem_pthread.dylib             0x00000001ae55eb40 _pthread_wqthread + 284 19  libsystem_pthread.dylib             0x00000001ae55d904 start_wqthread + 8 )
Replies
0
Boosts
0
Views
865
Activity
Dec ’22
StoreKit2: save currentEntitlements in keychain
Hi, With StoreKit2 giving us the up-to-date subscription status using Transaction.currentEntitlements, is there any value in storing the status separately in keychain as well? Or will that just add an unnecessary layer to manage (and possibly mess up)? I just want to subscription status to know if I need to unlock certain features in the app or not, and wondering if just looking at currentEntitlements and saving that in my Store object is enough. Thanks.
Replies
1
Boosts
0
Views
889
Activity
Oct ’22
StoreKit 2 - Issue
Hello, Im trying to use in-app purchases for first time. I have followed the tutorial for StoreKit 2 from the WWDC21 and in the simulator with the StoreKit Configuration File all was OK. But now I want test to the real server and I have this response: Error enumerating unfinished transactions for first transaction listener: Error Domain=ASDErrorDomain Code=509 "No active account" UserInfo={client-environment-type=Sandbox, storefront-country-code=USA, NSLocalizedDescription=No active account} In "Run" -> "StoreKit configuration" I have selected none In AppleStoreConnect I have created the auto-renewal suscription like in my StoreKit configuration. Also I create a new StoreKit configuration from the AppleStoreConnect and with this file its OK too. None of my testflight testers can see the options to purchase. I dont create any sandbox user. It's the problem? I saw in the documentation thats not needed. I am thankful for any kind of help. David
Replies
2
Boosts
1
Views
3.1k
Activity
Oct ’22
StoreKit 2: `try await Product.products` does not finish and does not throw. Can watchOS fetch products on TestFlight builds? iOS works
I am using a class that targets both my iOS as well as my watchOS target - so both use the same code. If I upload my code to TestFlight, my iPhone is able to fetch the products just fine. However, with my Apple Watch, the process seems to stall. I have implemented a log stream so that I can gather log output in TestFlight builds (where Xcode is not attached). This is my code: do { log("1") // reaches statement on iPhone, reaches statement on Watch let storeProducts = try await Product.products(for: productIDs) log("2") // reaches statement on iPhone, DOES NOT reach statement on Watch } catch { log("3") // does not get called on Watch either } Now unless I misinterpret the log statements, it looks like try await Product.products(for: productIDs) neither returns, nor throws. I have kept open my ViewController for minutes but there is no progress. My situation right now is the following: I have an app live that employs SwiftyStoreKit. This however breaks on iOS 16 so we are now moving over to StoreKit (2) for iOS 16 and watchOS 9 devices (older versions will stay on SwiftyStoreKit). Publishing a release without verifying in TestFlight is very risky so I am hoping someone can confirm that this is an issue with StoreKit 2 that TestFlight versions cannot fetch products in watchOS. However I cannot find any information from Apple or in any forum on this. We have also tried implementing the purchases via RevenueCat which also threw some weird errors (like this one https://community.revenuecat.com/sdks-51/receipt-is-missing-when-trying-to-purchase-via-testflight-1491) especially on watchOS. The Sandbox and TestFlight environments are known to be very buggy but it's a huge risk now to push an update without being able to confirm that it actually works at least once. Weirdly enough, with SwiftyStoreKit I can still see all my purchases in TestFlight which makes me think that the issue is on StoreKit 2's side - as SwiftyStoreKit still uses StoreKit 1 but without any other information on this that's purely speculation. So I'm hoping someone has ran into the same issue and knows more than I do.
Replies
1
Boosts
0
Views
1.4k
Activity
Sep ’22
StoreKit 2 in-app purchase restore
Apps that support in-app purchases are rejected in App Review unless they implement the ability to restore previous purchases. There is a WWDC 2022 video on doing exactly that and I am doing what that video suggests, but my app is still rejected. Here's what they say: "When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code "Sandbox receipt used in production," you should validate against the test environment instead." To which I replied: "I don’t have a server. Can you explain what “your server” means for an iOS app that has no server-side components?" But they won't explain themselves. They just say: "Your question requires technical assistance and would be best addressed by Apple Developer Technical Support who can provide discrete code-level assistance for Apple frameworks, APIs, and tools." Can someone point me to a code example that shows how to do this? My failed attempt is here: https://github.com/mvolkmann/SwiftUI-GiftTrack/blob/main/GiftTrack/ViewModels/StoreViewModel.swift
Replies
2
Boosts
0
Views
4.2k
Activity
Sep ’22
While trying to purchase from sandbox its showing me that error in Xcode 13 and iOS 14.3
<SKPaymentQueue: 0x282526050>: Payment completed with error: Error Domain=ASDErrorDomain Code=500 "Unhandled exception" UserInfo={NSUnderlyingError=0x28280aee0 {Error Domain=AMSErrorDomain Code=301 "Invalid Status Code" UserInfo={NSLocalizedDescription=Invalid Status Code, NSLocalizedFailureReason=The response has an invalid status code}}, NSLocalizedFailureReason=An unknown error occurred, NSLocalizedDescription=Unhandled exception}
Replies
0
Boosts
0
Views
916
Activity
Jul ’22
The resource 'inAppPurchasePriceSchedules' does not exist (PATH_ERROR)
StoreKit Configuration Sync with App Store Connect is not valid: The URL Path is not valid The resource 'inAppPurchasePriceSchedules' does not exist (PATH_ERROR)
Replies
0
Boosts
0
Views
1.2k
Activity
Jul ’22
Strange runtime error when using StoreKit Test API
We are trying to integrate StoreKit Testing into our unit and UI testing flow on Mac and iOS. The basic idea is bypassing the paywall so that the specific test can do its job without interference. In our subclass of XCUIApplication, we've overridden the launch method to simulate the purchase of the app's full version: import XCTest import StoreKitTest class OurCustomApp : XCUIApplication { private var _storeKitSession : AnyObject? = nil override func launch() { super.launch() do { _storeKitSession = try SKTestSession(configurationFileNamed: "iap_desktop") (_storeKitSession as! SKTestSession).disableDialogs = true (_storeKitSession as! SKTestSession).clearTransactions() try (_storeKitSession as! SKTestSession).buyProduct(productIdentifier: "<our product identifier>") } catch { XCTFail("Can't setup StoreKit test. \(error)") } } } However, we faced a weird runtime issue: UITests-Runner[53387:25779369] Error in XPC connection when checking Xcode Test app: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.storekitagent was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.storekitagent was invalidated: failed at lookup with error 159 - Sandbox restriction.} We use the proper certificate for StoreKit Testing and follow all the steps from Setting Up StoreKit Testing in Xcode. The problem reproduces on all our machines, including Intel-based and M1 Macs. We'd appreciate any hints or clues that will help us resolve this issue.
Replies
1
Boosts
0
Views
1.7k
Activity
Jun ’22