无法为非续订订阅恢复已完成的交易

Can't restore completed transactions for non-renewing subscriptions

我有 非续订订阅 类型的产品,我需要恢复用户之前进行的交易的功能。我购买了几个这样的产品并想恢复它们。我使用这个典型的代码:

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

但是我 paymentQueueRestoreCompletedTransactionsFinished: 没有任何恢复的交易。我对测试用户使用沙箱环境。

iTunes 应用商店不会恢复非续订订阅。您的应用有责任跟踪用户的订阅状态 -

来自In-App Purchase Programming Guide

Non-renewing subscriptions differ from auto-renewable subscriptions in a few key ways. These differences give your app the flexibility to implement the correct behavior for your needs, as follows:

Your app is responsible for calculating the time period that the subscription is active and determining what content needs to be made available to the user. Your app is responsible for detecting that a subscription is approaching its expiration date and prompting the user to renew the subscription by purchasing the product again.

Your app is responsible for making subscriptions available across all the user’s devices after they’re purchased and for letting users restore past purchases. For example, most subscriptions are provided by a server; your server would need some mechanism to identify users and associate subscription purchases with the user who purchased them.