Testing SubscriptionsMarch 23, 2021 -
If you are working on subscriptions through Apple's in-app-purchase system, here are some tips that might help you:
1. Making New Sandbox Users
While Apple officially recommends using the trick where inserting the plus sign and any addition before the name part of your email (aka subaddressing) to make new accounts, the form in App Store Connect will not let you do it. Apple's new security requirements affect even these sandbox accounts, so you will need to provide a valid email, but it can't be one used for an Apple ID before. So here's the trick, you can put in any email-looking gibberish in the form on the web page to make the account. When you try to use that account on your phone, it will prompt you to configure 2-factor authentication and there it will give you a chance to chose a different email address. Here you can use the "+" to give it a valid email by subaddressing your own email address. I don't know why this works, but the web page does not let you do it. Especially since Apple endorses this practice. I do know that now this won't suck up more hours of your day!
2. Accessing the Receipt File
You may want to have the receipt file to use for your own tests or to send off to someone on your backend team. If you're working on an iOS app, this isn't super convenient to access without some tricks, but here is some code that will let you get to the file without any additional setup.
let shareController = UIActivityViewController(activityItems: [ Bundle.main.appStoreReceiptURL as Any ], applicationActivities: nil) present(shareController, animated: true, completion: nil)
Have this code run on launch or when some button in your app is tapped and you'll have a share sheet with options like AirDrop to pass the file off to whoever needs it. This also works when you want to send off database files and such in your app.
3. Expiring Subscriptions
Even if your subscriptions are auto-renewing, sandbox subscriptions will expire. They will renew, but only a limited number of times. Sandbox subscriptions also operate on an accelerated time-scale, so a year's worth of subscription will only take an hour. Once a subscription expires, you cannot just buy a new subscription from inside the app. Your users will need to go into the App Store App app on their phones and re-subscribe from the subscription interface there. Your sandbox tester account, however, behaves differently. You'll need to go into the Settings app, find the entry for the App Store, and look for the sandbox-specific bits there. Apple's Documentation covers this process fairly well.