According to the Apple In App Purchase Programming Guide:
The App Store creates a separate transaction eac开发者_JAVA技巧h time it renews a subscription. When your application restores previous purchases, Store Kit delivers each transaction to your application.
Let's imagine my app subscription is client-side-only (no server component). The simplest way to verify that subsequent renewals have been billed seems to be restoring previous purchases every month.
However, this pops up the user's iTunes password prompt every time you call restoreCompletedTransactions
which seems like bad user experience. Is the only recourse to use the server receipt verification code (along with the new "shared secret")?
The App Store calls the paymentQueue and posts a transaction each time it auto-renews. The transaction is posted with transaction.transactionState==SKPaymentTransactionStateRestored.
The issue is that unfortunately this gets posted only to one device. A second device does not get the posting. Therefore, to detect the auto-renewal, or rather to detect the lack of an autorenewal and deny any device a continuing subscription, you have to do a restoreCompletedTransaction or "http post a 64-bit encoded JSON containing the last transaction". If the fomer, the user needs to give their password; and as you point out, that's intrusive. If the latter, lots of additional coding is required. So, my question in answering your question is...why doesn't StoreKit have a command:
(does not exist) - [[SKPaymentQueue defaultQueue] restoreAttachedTransactions:(NSArray *)transactions];
This command would flow just like a restoreCompletedTransactions but it would only restore the attached transactions and, most importantly, it would not require log-in by the user. It has the same security protection as the "http post a 64-bit encoded JSON containing the last transaction" and it allows the entire In App Purchase process to be done in StoreKit rather than requiring web posting code.
If this makes sense to you, please suggest how to get this to Apple....thanks.
If you have no server component, the only place you can store this information is in a local file/database/config
The restoreCompletedTransactions option is there for when there is something wrong with your local database, you should put a button somewhere on your advanced settings panel to restore all previous transactions.
So, you will have to trust the data you store locally. Normally, this is safe as you cannot change your local filesystem (unless you jailbreak). If you don't want to trust your users like that, you can optionally encrypt it...
精彩评论