Open Seoras opened 9 years ago
I reach the same issue. I find the code in RMStore.m line 623: [queue startDownloads:downloads];
That means after restore finished, all the content will start download again. I think adding a property to indicate which product IDs no need to be re-downloaded will fix.
I changed the code below temporary: I add a NSArray *_restoreSkipReDownloadProductIDs;
- (void)didDownloadSelfHostedContentForTransaction:(SKPaymentTransaction *)transaction queue:(SKPaymentQueue*)queue
{
NSArray *downloads = transaction.downloads;
NSMutableArray *realyDownloads = [@[] mutableCopy];
if (downloads.count > 0)
{
for (SKDownload *download in downloads) {
if ([_restoreSkipReDownloadProductIDs containsObject: download.contentIdentifier]) {
[self finishTransaction:transaction queue:queue];
} else {
[realyDownloads addObject: download];
}
}
RMStoreLog(@"starting downloads for product %@ started", realyDownloads);
[queue startDownloads:realyDownloads];
} else {
[self finishTransaction:transaction queue:queue];
}
}
Sure, I changed a little to the restore function:
- (void)restoreTransactionsOnSuccess:(void (^)(NSArray *transactions))successBlock
failure:(void (^)(NSError *error))failureBlock
{
[self restoreTransactionsBySkipReDownloadProductID: nil
OnSuccess: successBlock
failure: failureBlock];
}
- (void)restoreTransactionsBySkipReDownloadProductID:(NSArray *)skipReDownloadProductIDs
OnSuccess:(void (^)(NSArray *transactions))successBlock
failure:(void (^)(NSError *error))failureBlock;
{
_restoreSkipReDownloadProductIDs = skipReDownloadProductIDs;
_restoredCompletedTransactionsFinished = NO;
_pendingRestoredTransactionsCount = 0;
_restoredTransactions = [NSMutableArray array];
_restoreTransactionsSuccessBlock = successBlock;
_restoreTransactionsFailureBlock = failureBlock;
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
@hpique Will you update the code?
If I'm reading the API correctly then I'm assuming restoreTransactionsOnSuccess: downloads all available purchased content before calling any delegate or block. With the exception being storeDownloadUpdated:
Is there anyway to discover what content is available for restore and selectively restoring?