簡體   English   中英

如何根據Apple ID檢查已購買或未使用iOS中的應用程序內購買的用戶

[英]How to check user already purchased or not using In-App Purchase in iOS based on apple ID

我想知道如何根據蘋果ID檢查是否已購買,因為我沒有在我的應用程序中登錄。

以下是我的代碼:

(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
}

任何幫助如何進行?

您的應用程序通過調用來啟動該過程

SKPaymentQueue類的restoreCompletedTransactions方法

這會向App Store發送請求以恢復所有應用已完成的交易。 如果您的應用為其付款請求的applicationUsername屬性設置了值,如檢測不規則活動中所述,請使用

restoreCompletedTransactionsWithApplicationUsername:

恢復事務時提供相同信息的方法。

對於每個已還原的事務,將調用事務隊列觀察器,其狀態為SKPaymentTransactionStateRestored,如等待App Store處理事務中所述。 您此時采取的操作取決於您的應用程序的設計。

NSMutableArray *productIDsToRestore = <# From the user #>;
SKPaymentTransaction *transaction = <# Current transaction #>;

if ([productIDsToRestore containsObject:transaction.transactionIdentifier]) {
    // Re-download the Apple-hosted content, then finish the transaction
    // and remove the product identifier from the array of product IDs.
} else {
    [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}

此處閱讀Apple文檔。

您可以使用 - [SKPaymentQueue restoreCompletedTransactions]從商店獲取以前的交易列表。 恢復的事務可以像正常事務一樣進行驗證。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM