Using appStoreReceiptURL to restore non-renewing s

2019-05-24 12:34发布

问题:

I can use the receipt obtained by appStoreReceiptURL to retrieve the purchase date of non-renewing subscription. For non-renewing subscription, from the purchase date I could calculate the expiration date.

But when I try to restore using appStoreReceiptURL. I found that it returns nil on devices that did not make purchase even signing in with the same Apple ID.

Using

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

cannot update the receipts in appStoreReceiptURL. Did I do anything wrong here? Or is it just not possible to restore the receipts this way?

Thanks

回答1:

You cannot restore the transactions in the way you are trying as they are consumables, and consumables have a finite life.

However, you could parse the receipt, and calculate the subscription period from this.

The receipt will be in the main bundle, but can be refreshed by using

recreq = [[SKReceiptRefreshRequest alloc] init];
        [recreq setDelegate:self];
        [recreq start];