如何从恢复的交易中获取产品标识符?

发布于 2025-01-06 21:03:44 字数 71 浏览 0 评论 0原文

我已成功恢复应用内交易并从原始交易中获取交易标识符,但如何识别交易中购买的产品? 是否可以获取之前购买的应用内商品的商品标识符?

I have managed to restore in-app transactions and get the transaction identifier from the original transaction, but how do I identify the product which were bought in the transaction?
Is it possible to get the product identifier for a previously purchased in-app product?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

森林散布 2025-01-13 21:03:44

如果您的意思是您想检查已经用户购买的已购买商品..是的,您可以这样做

- (void) checkPurchasedItems {
    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
} //You Call This Function

//Then this delegate Function Will be fired
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
    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];
    }
}

if you mean you want to check the purchased items that already user buy it .. yes you can do like this

- (void) checkPurchasedItems {
    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
} //You Call This Function

//Then this delegate Function Will be fired
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
    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];
    }
}
铃予 2025-01-13 21:03:44

SWIFT 版本:

一旦您获得委托

func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {
    var productIds = [String]()
    for transcation in queue.transactions{
        if let productID = transcation.payment?.productIdentifier{
        productIds.append(productID)
        }
    }

SWIFT VERSION:

Once you get the delegate

func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {
    var productIds = [String]()
    for transcation in queue.transactions{
        if let productID = transcation.payment?.productIdentifier{
        productIds.append(productID)
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文