没有什么可恢复时显示警报
Show alert when there's nothing to restore
我在我的应用程序中实现了应用程序内购买以及恢复。我的问题是:如果我按下恢复按钮,没有任何东西可以恢复,我怎么知道呢?
现在,如果我点击恢复按钮并且用户以前购买过东西,它会恢复并显示一条消息。但是如果没有什么可以恢复它什么也做不了,我想告诉用户一些事情。
谢谢
更新:
我通过检查进行的交易数量修复了它,如果它 = 0 则没有任何东西可以恢复:
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
NSMutableArray *purchasedItemIDs = [[NSMutableArray alloc] init];
if (queue.transactions.count == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You don't have anything to restore" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
for (SKPaymentTransaction *transaction in queue.transactions) {
NSString *productID = transaction.payment.productIdentifier;
[purchasedItemIDs addObject:productID];
[_transactionDelegate inAppPurchaseHelper:self transaction:productID didFinish:YES];
}
}
恢复完成后调用paymentQueueRestoreCompletedTransactionsFinished
方法。同时,跟踪您收到的 SKPaymentTransactionStateRestored
.
类型的交易数量(如果有)
如果它为零,那么您就知道什么都没有恢复。
我在我的应用程序中实现了应用程序内购买以及恢复。我的问题是:如果我按下恢复按钮,没有任何东西可以恢复,我怎么知道呢?
现在,如果我点击恢复按钮并且用户以前购买过东西,它会恢复并显示一条消息。但是如果没有什么可以恢复它什么也做不了,我想告诉用户一些事情。
谢谢
更新:
我通过检查进行的交易数量修复了它,如果它 = 0 则没有任何东西可以恢复:
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
NSMutableArray *purchasedItemIDs = [[NSMutableArray alloc] init];
if (queue.transactions.count == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You don't have anything to restore" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
for (SKPaymentTransaction *transaction in queue.transactions) {
NSString *productID = transaction.payment.productIdentifier;
[purchasedItemIDs addObject:productID];
[_transactionDelegate inAppPurchaseHelper:self transaction:productID didFinish:YES];
}
}
恢复完成后调用paymentQueueRestoreCompletedTransactionsFinished
方法。同时,跟踪您收到的 SKPaymentTransactionStateRestored
.
如果它为零,那么您就知道什么都没有恢复。