2

有时下载失败,我的应用程序在失败时完成交易,正如在任何地方推荐的那样。但是,如果我完成交易,那么 Store Kit 将无法恢复失败的下载。而且一旦下载失败,Store Kit似乎也不会自动重试下载内容,而且似乎也没有办法触发下载。

有人知道在这种情况下该怎么做吗?违背所有建议,直到内容完全下载和安装后才完成交易?

还是我必须以编程方式恢复交易并忽略所有其他产品标识符?

4

1 回答 1

1

您可以通过这种方式在您的应用程序中添加恢复购买按钮:-

//inside of an IBaction
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue]restoreCompletedTransactions];


// Then this is called
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
NSLog(@"%@",queue );
NSLog(@"Restored Transactions are once again in Queue for purchasing %@",[queue transactions]);  

NSMutableArray *purchasedItemIDs = [[NSMutableArray alloc] init];
NSLog(@"received restored transactions: %i", queue.transactions.count);

for (SKPaymentTransaction *transaction in queue.transactions) {
    NSString *productID = transaction.payment.productIdentifier;
    [purchasedItemIDs addObject:productID];
    NSLog (@"product id is %@" , productID);
    // here put an if/then statement to write files based on previously purchased items
    // example if ([productID isEqualToString: @"youruniqueproductidentifier]){write files} else { nslog sorry}
  }  
 }

或者

 [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

希望这对你有帮助......!

于 2013-05-28T09:47:40.600 回答