【问题标题】:Show alert when there's nothing to restore没有可恢复的内容时显示警报
【发布时间】:2023-03-10 07:00:01
【问题描述】:

我在我的应用中实现了应用内购买以及恢复功能。我的问题是:如果我按下恢复按钮并且没有任何东西可以恢复,我怎么知道呢?

现在,如果我点击恢复按钮并且用户之前购买过东西,它将恢复并显示一条消息。但是,如果没有什么可以恢复,它不会做任何事情,我想告诉用户一些事情。

谢谢

更新:

我通过检查进行的交易数量来修复它,如果它是 = 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];

    }
}

【问题讨论】:

    标签: ios in-app-purchase restore


    【解决方案1】:

    还原完成时调用paymentQueueRestoreCompletedTransactionsFinished 方法。同时,跟踪您收到的SKPaymentTransactionStateRestored 类型的交易数量(如果有)。

    如果它是零,那么你就知道什么都没有恢复。

    【讨论】:

    • 我无法让它工作.. 我正在使用 InAppPurchaseHelper 类,我正在恢复:[[InAppPurchaseHelper sharedManager] restoreCompletedTransactionsBy:self] ;
    • 您需要使用问题的相关详细信息更新您的问题。如果你什么都不告诉我们你在做什么,只是说“它不起作用”,没有人可以提供帮助。
    • 谢谢,我搞定了。一开始我没听懂你说的。
    猜你喜欢
    • 2017-06-29
    • 1970-01-01
    • 1970-01-01
    • 2020-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多