Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should happen when non-purchased user press the restore purchase button in iOS?

My sandbox test account can purchase non-consumable item and restore it. Everything works. However, if the account have not purchased the item before, pressing the restore button does nothing. I see nothing in the debug panel. I'm expecting iOS to detect if a certain user has purchased the item or not, if not then display a message asking them to buy it. Does it work like that or the current behavior is totally acceptable?

Here is the restore purchase code (Swift) connecting to a button inside the main storyboard:

@IBAction func restoreButtonPressed(sender: UIButton) {
    statusLabel.text = "Status: Restoring Purchase"
    SKPaymentQueue.defaultQueue().addTransactionObserver(self)
    SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
}

Other implemented methods include:

Works for normal purchase

func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!) {}

Works for normal restore

func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {}

Never see messages coming from this method before

func paymentQueue(queue: SKPaymentQueue!, restoreCompletedTransactionsFailedWithError error: NSError!) {}

Thanks!

like image 652
Lê Hoàng Avatar asked Apr 21 '15 07:04

Lê Hoàng


People also ask

What happens if you click restore purchases?

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.

What does restore purchases do on iPhone?

You can redownload items purchased from the App Store, Book Store, Apple TV app, and iTunes Store without repurchasing them. If you're part of a Family Sharing group, you can download items purchased by other family members, too.

Does restore purchases mean refund?

"Restore Purchases" reinstates purchases that haven't been automatically restored, eg. if you are transferring data to a new device. It's not a way to refund your purchases. That needs to go through the store (Apple or GooglePlay).

What does the Restore Purchases button do in games?

The "Restore Special Purchases" option allows a new game to restore dresses, bags and other special App Store purchases - items other than in-game currency - to be replaced.


1 Answers

You can check if the queue has any returned transactions, and if not it means that there are no purchases to restore:

func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {
  if queue.transactions.count == 0 {
    let alert = UIAlertView()
    alert.title = "Oops"
    alert.message = "There are no purchases to restore, please buy one"
    alert.addButtonWithTitle("Buy")
    alert.addButtonWithTitle("Cancel")
    alert.show()
 }
}
like image 189
Nyfa117 Avatar answered Sep 21 '22 05:09

Nyfa117