title: In-App-Purchase Remove From Queue
body: <p>I am new on iOS, i am trying to download 3 products from my service but the user needs to buy these products, i have 3 buttons, i click first one and after enter username and password, it is downloading, then i click second product, firstly it is downloading first product then second product,then i click third product, it is downloading first->second->third product.How can i remove the first product from the queue after download first product? Sorry for my bad english.</p>
  
  <p>Thanks.</p>
  
  <p>Best Regards.</p>
  
  <pre><code>    - (IBAction)downloadButtonPressed:(id)sender {
          SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"com.company.testtest123"];
          [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
          [[SKPaymentQueue defaultQueue]addPayment:payment];
      }
  
  
              - (void)paymentQueue:(SKPaymentQueue *)queue removedTransactions:(NSArray *)transactions  {
    for (SKPaymentTransaction *transaction in transactions) {
          // Count down
          @synchronized(self) {
              NSInteger numOfTransaction = [[NSUserDefaults standardUserDefaults] integerForKey:@"NumberOfTransactions"];
              [[NSUserDefaults standardUserDefaults] setInteger:numOfTransaction-1 forKey:@"NumberOfTransactions"];
              [[NSUserDefaults standardUserDefaults] synchronize];
          }
      }
  }
  -(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
      SKProduct *validProduct =nil;
  
      int count = [response.products count];
  
      if (count&gt;0) {
          validProduct =[response.products objectAtIndex:0];
      }else if(!validProduct){
  
          NSLog(@"No products avaible");
  
      }
  
  }
  -(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
  
      for (SKPaymentTransaction *transaction in transactions) {
          switch (transaction.transactionState) {
              case SKPaymentTransactionStatePurchasing:
  
                  break;
  
              case SKPaymentTransactionStatePurchased:{
                  //download kismi buraya
  
                  NSLog(@"_mainDict = %@",_mainDict);
  
                  float _csize = (float) 0 / 1024;
                  float _tsize = (float) [[_mainDict valueForKey:@"Size"] integerValue] / 1024;
                  NSString *strDownload = [NSString stringWithFormat:@"downloading \n (%0.2f MB/%.2f MB)",_csize,_tsize];
                  [SVProgressHUD showProgress:0 status:strDownload maskType:SVProgressHUDMaskTypeBlack];
  
  
                  [service servicePicList];
  
  
                  [[SKPaymentQueue defaultQueue]finishTransaction:transaction];
  
                  break;
              }
  
              case SKPaymentTransactionStateRestored:{
                  [[SKPaymentQueue defaultQueue]finishTransaction:transaction];
  
  
                  break;
              }
  
              case SKPaymentTransactionStateFailed:
              {
                  if (transaction.error.code != SKErrorPaymentCancelled) {
                      NSLog(@"An error encountered");
                  }
  
                  [[SKPaymentQueue defaultQueue]finishTransaction:transaction];
                  break;
  
              }
  
          }
      }
  
  }
  
  
  
  
  - (void)failedTransaction:(SKPaymentTransaction *)transaction {
  
      NSLog(@"failedTransaction...");
      if (transaction.error.code != SKErrorPaymentCancelled)
      {
          NSLog(@"Transaction error: %@", transaction.error.localizedDescription);
      }
  
      [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
  }
  </code></pre>