I have a Restore button. The problem is if they havent' done a restore, and they try to purchase an item, and they have already purchased that item, I need to tell them they already purchased it and not perform the purchase. So I need a way to know, without doing a restore, which items they've purchased. I tried doing a restore first, whenever the user tries to purchase, but apple rejected my app. They said a restore cannot occur before the Confirm In-App Purchase dialog is displayed.
Please help me to find the right way.
Thanks in advance.
Restoring purchases is a mechanism by which your user can restore their in-app purchases, reactivating any content that had previously been purchased from the same store account (Apple, Google, or Amazon).
Restoring purchases prevents you from losing all the things that have been purchased on the old devices. All you need to do is sign in with your old Apple ID or Google Account credentials and you would have restored your purchases. Pretty simple, correct? This menu is available on the side menu of your app.
Open the drawer from the upper left corner of the screen and select Support. Select Purchases and Paid App from the menu. Tap on the menu option, located in the upper right-hand corner of the screen. Tap on Recover Paid App.
You can keep those data in NSUserDefaults. And you don't need to show an Alert saying that the items are already purchased. If its a non-consumable product apple is showing the alert saying that they have already purchased that item!
EDIT:
1) You need to add 3 buttons to your view
You need to give the user the restore option if you supports in-app purchases in your app. Otherwise Apple will reject your app.
2) If the user press the Buy Button, don't check whether the user has already purchased your app or not. Because Apple won't charge the users twice for the same non-consumable product. So just go through your buying code and if the the user has already purchased it Apple's StoreKit framework will call it's delegate method
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
with
SKPaymentTransactionStatePurchased
transaction state. So you can present him the login screen.
3) If the user press the Restore Button just go through with your restore code
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
and like in the 2nd step it will call the delegate method with the same transaction state. So you can present the login page to the user.
4) If the user press the Demo version button, Present him the demo version.
5) If a user purchased your app, Deleted it and if he re-install it, treat him as a new user. Present him those 3 buttons and the user can restore the purchase and then you can present him the login page.
6) If you really need to keep on track whether the app is purchased on a exact device, then you can use the Keychain to store your data, because the Keychain items are not deleted even if the app is Uninstalled or removed. This Api will help a lot link, have a look
or
You can refer to Apple's documentation on Keychain data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With