问题
I have the following questions regarding iOS auto-renewable subscriptions
a) Are auto-renewal subscriptions really auto-renewing in the sandbox environment? The problem seems to be that subscriptions are not renewed automatically although the documentation says that even in sandbox environment it should happen 6 times.
b) Do we need to call restoreCompletedTransactions to get new receipt for automatically extended subscription, or is -paymentQueue:updatedTransactions: method called automatically by iOS? (I guess it automatically called on 'launch' & 'rotation out of background' not sure)
c) How have you handled the same subscription on multiple devices? This can be handled by restoreCompletedTransactions, but calling it will prompt users password, so it is not very handy to call it every time the app starts.
回答1:
a) Auto-renewing subscriptions are inconsistent in the sandbox environment. Sometimes a subscription will renew multiple times (about 5) before ending. Other times it won't renew at all.
b) (iOS6 transaction receipts only) You don't need to call restoreCompletedTransactions
to check the status of a subscription if you're storing previous receipts (preferably on your server). Just take any subscription receipt you've stored for that user and submit it to the App Store for verification. They'll respond with the latest_receipt_info
including the expires_date
which you can use to determine current subscription status.
c) You should prompt new users to "Restore Previous Purchases" at which point you call restoreCompletedTransactions. Then submit one of those receipts (preferably from your server) to the App Store for verification to get decoded details about the transaction. Look for the key original_transaction_id
in the receipt info. This will always contain the id of the very first time this user initiated a subscription with you. If you compare this ID to others in your system, you should be able to determine which devices share an Apple account. (Since Apple doesn't allow you to see a user's Apple ID, this is the best way to identify an account that spans multiple devices).
Similar to this question: iOS auto-renew expired at the end of current subscription period
回答2:
To add to this it seems that the line in Apple's documentation is being misinterpreted
Renewal happens at an accelerated rate, and auto-renewable subscriptions renew a maximum of six times per day. This lets you test how your app handles a subscription renewal, a subscription lapse, and a subscription history that includes gaps.
This seems to mean that all subscriptions per day will only renew 6 times. Rather than each subscription will renew 6 times before canceling. This threw me for a while.
It also seems to be in a 24 hour period. Not refreshing at a given time. For example, I made a subscription at 11am that did not renew. I made one again at 2pm that renewed 6 times.
来源:https://stackoverflow.com/questions/8033673/ios-sandbox-environment-auto-renewal-subscription