Ios how to get a list of already purchased products?
See the Restoring Transactions section of the In-App Purchase guide. Here is what it specifically says:
Store Kit provides built-in functionality to restore transactions for
non-consumable products, auto-renewable subscriptions and free
subscriptions. To restore transactions, your application calls the
payment queue’s restoreCompletedTransactions method. The payment queue
sends a request to the App Store to restore the transctions. In
return, the App Store generates a new restore transaction for each
transaction that was previously completed.
How to get List of Only Purchased Product Ids fron inApp in ios?
You can restore the purchases by using :
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
then SKPaymentTransactionObserver will call its
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
with the SKPaymentTransactionStatePurchased transaction state. You can see that it returns an Array for the transactions.
You can get a single transaction using,
for (SKPaymentTransaction * transaction in transactions) {
NSLog(@"Purchased indentifier : %@", transaction.payment.productIdentifier);
}
This will print out the identifiers that the user have purchased. You can set your NSUserDefaults regarding to these values
How to fetch already purchased details of iOS IAP Auto Renewable product
There is two way to get user purchased transaction details:
- Refresh receipt
- Restore completed transaction
To know more about difference between refreshing receipt & restore transaction in details, Please check:- SKReceiptRefreshRequest vs restoreCompletedTransactions
In Simply,
- Refreshing the receipt asks the App Store for the latest copy of the receipt.
- Restoring completed transactions creates a new transaction for every completed transaction the user made, essentially replaying history for your transaction queue observer.
Question:
How I can get that purchased details (atleast original receiptID) as we get in Initial transaction.
Answer: If you want to verify user with original receiptID every time each time than user SKReceiptRefreshRequest for validating user transaction.
Note: Anytime if you validating user with RestoreCompletedTransactions, Your transactionID will change.
Find list of parameter that change while restoreTransaction: https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1
Related Topics
How to Prevent Duplicates in Realmswift List
Apns Http2 API Not Returning Status 410 After Uninstalling App
Left-To-Right Mark Not Working in Swift
Responseserializer 'Cannot Call Value of Non-Function Type 'Nshttpurlresponse'' with Swift 3
Pass Extra Argument for UItapgesturerecognizer with Selector
Cocos2D Sprite Repeat Animation Forever
App Could Not Authenticate with Facebook and Firebase After Conversion to Swift 3 Syntax
iOS UIlabel Autoshrink So Word Doesn't Truncate to Two Lines
How to Make Collage of Images According to Different Shapes
Notification in Swift Every Day at a Set Time
How to Go to Specific Native View Controller from React-Native Code
Svg Viewbox Height Issue on iOS Safari
How to Connect Xcode 9 and Github
How to Add a Lock Screen Widget (Requiring iOS 16) and Still Support iOS 15
Progress of a Alamofire Request