title: Restoring purchases in iOS
body: <p>I am working on restoring purchases, So I have few doubts</p>
  
  <p>1) How to show restore button</p>
  
  <p>I have shown it on top left corner, and on click of it I call this function</p>
  
  <pre><code>- (IBAction)restorePurchases:(id)sender
      {
          [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
          [[SKPaymentQueue defaultQueue]restoreCompletedTransactions];
  
      }
  </code></pre>
  
  <p>But What if the user has not purchased anyItem or what if the user has purchased an item but not deleted and reinstalled the app, Whether I still need to show the restoreButton, and if yes, on click of it what should be its behaviour.</p>
  
  <p>2) Now, If I have made a purchase of an item and delete the app and reinstall the app, and click on restore button, it calls this function</p>
  
  <pre><code>- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
  {
      for (SKPaymentTransaction *transaction in transactions)
      {
          switch (transaction.transactionState)
          {
              case SKPaymentTransactionStatePurchased:
                  [self completeTransaction:transaction];
                  break;
              case SKPaymentTransactionStateFailed:
                  [self failedTransaction:transaction];
                  break;
              **case SKPaymentTransactionStateRestored:
                  [self restoreTransaction:transaction];**
              default:
                  break;
          }
      }
  }
  </code></pre>
  
  <p>But now, suppose I dont but anyitem and simply click restore button, it asks me for my apple Id, after entering apple Id, nothing happens, It doesnt call the above function, I want to know why this is happening.</p>
  
  <p>Also, I want to display a message to user that there are no items to restore, so how can I do that.</p>
  
  <p>I searched for this and their is one delegate function which will be called,if there are no transactions to retore</p>
  
  <pre><code>- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
  {
  
  }
  </code></pre>
  
  <p>What I have done is that here I have checked if there are no items to restore, I will display as no items to restore, whether I am right in this approach.</p>
  
  <p>Regards
  Ranjit</p>