title: iOS InApp purchase updatedTransactions: cannot distinguish between new purchase and restore
body: <p>As I know that Apple recommands to get a Buy and a Restore button (I have these in the settings view of my application), on other views I only have the purchase button.</p>
  
  <p>When a user clicks on the "Buy" button and Apple detects that this user already has purchased this product, he will ask the user to restore this purchase for free (everything is fine here). When the user clicks yes, then <code>updateTransactions:</code> is called and it always goes on the <code>case SKPaymentTransactionStatePurchased:</code> and not in the <code>case SKPaymentTransactionStateRestored:</code>.</p>
  
  <p>Why is that ? Is there a way to distinguish the <em>restore</em> from the <em>new purchase</em> with <code>updatedTransactions:</code> ?</p>
  
  <pre><code>- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
      id&lt;GAITracker&gt; tracker = [[GAI sharedInstance] defaultTracker];
      for(SKPaymentTransaction *transaction in transactions){
          switch (transaction.transactionState){
              case SKPaymentTransactionStatePurchasing: //NSLog(@"Transaction state -&gt; Purchasing");
                  //called when the user is in the process of purchasing, do not add any of your own code here.
                  break;
              case SKPaymentTransactionStatePurchased:
                  //this is called when the user has successfully purchased the package (Cha-Ching!)
                  [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Purchase" action:@"Purchase Completed!" label:shopNameSelected value:nil] build]];
                  [self doGoPremium];
                  [MBProgressHUD hideHUDForView:self.view animated:YES];
                  [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                  //NSLog(@"Transaction state -&gt; Purchased");
                  break;
              case SKPaymentTransactionStateRestored:
                  //NSLog(@"Transaction state -&gt; Restored Here");
                  //add the same code as you did from SKPaymentTransactionStatePurchased here
                  [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Purchase" action:@"Purchase Restored" label:shopNameSelected value:nil] build]];
                  [self doGoPremium];
                  [MBProgressHUD hideHUDForView:self.view animated:YES];
                  [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                  break;
              case SKPaymentTransactionStateFailed:
                  //called when the transaction does not finnish
                  [MBProgressHUD hideHUDForView:self.view animated:YES];
                  if(transaction.error.code != SKErrorPaymentCancelled){
                      //NSLog(@"Transaction state -&gt; Cancelled");
                      //the user cancelled the payment ;(
                      // Add some analytics point.
                      [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Purchase" action:@"Purchase Canceled" label:shopNameSelected value:nil] build]];
                  }
                  [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
                  break;
          }
      }
  }
  </code></pre>