I'm running into some baffling issues related to testing Introductory Offers in the Sandbox environment using Sandbox Tester accounts. I've created an Introductory Offer for a single country (Armenia) to avoid presenting the offer for other countries in the live version of my app. I've also created a new Sandbox Tester with App Store Country set to Armenia, installed a test version of my app via XCode, and logged in with my Armenian Sandbox Account via Settings -> iTunes & App Store -> Sandbox Account. My goal is to test that the introductory offer is only presented if the logged-in user qualifies for it.
After loading product info via SKProductsRequest (which I do on app launch as well as a few other places), I expected introductoryPrice to be set for the related subscription product, but it was nil. However, after tapping my "Restore Purchases" button and reloading products, it was set! Then, I took an action that I knew would re-request products, and the field was again nil. At this point, I suspected that StoreKit was caching SKProductsResponses, so I put my device in airplane mode, disabled WiFi, and took another action to reload products. Lo and behold, I received a response via productsRequest:didReceiveResponse, even though I had no network connection. Certainly smells like caching...
Something that might be relevant: after restoring purchases, I always validate the receipt locally to determine the current state of the user's subscription. If the receipt is not available (which it often initially isn't when installing via XCode and/or using the Sandbox), I request it via SKReceiptRefreshRequest. Does the receipt impact how StoreKit fetches product information?
Another similar issue: if I log out of one Sandbox Account and into another located in a different country with different currency, the locale set on products is not correct when I relaunch my app, resulting in my store displaying the wrong currency. I would expect StoreKit to immediately return updated SKProduct records in this situation, but again, it doesn't until I run restore purchase/receipt validation.
To summarize, here are my questions:
- Does StoreKit cache SKProductsResponses? Is the behavior the same in the Sandbox vs. Production? If it does, is there a way to bypass the cache?
- When (if ever) does the system load a Sandbox Account's receipt?
- Does the receipt affect SKProductsRequest in any way?
- How should an app that presents information from SKProducts handle a user logging out of one Apple ID account an into another? An edge case, I know, but it's certainly possible...