title: Detecting cancel button on itunes login alertView for in-app purchases
body: <p>Searched for answer to this all over, can't find an answer.</p>
  
  <p>I have an app with IAP.  If the user is not logged into iTunes, they get a login prompt.  </p>
  
  <p>If they cancel from the Login prompt, I get a callback to <code>failedTransaction:transaction</code> but the error code is <code>0</code> (<em>which is enum as <code>SKErrorUnknown</code></em>).  </p>
  
  <p>So how do I distinguish between a cancel and another <code>SKErrorUnknown</code>, one of which is being in Airplane mode?  (<em>If they are in airplane mode the error code is also 0</em>).  </p>
  
  <p>I want to provide an alert in this case, but not if they hit Cancel.  </p>
  
  <p>Again - before someone misreads my question - the answer to this is NOT to test for SKErrorPaymentCancelled = 2.  </p>
  
  <p>You get this code when the user cancels the PURCHASE AFTER the login.  </p>
  
  <p>But I'm asking about cancelling the login.</p>
  
  <p>EDIT - maddy, really?  here's my code:</p>
  
  <pre><code>/**************************************************************************
   paymentQueue
   **************************************************************************/
  - (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;
          }
      };
  }
  
  /**************************************************************************
   failedTransaction
   *************************************************************************/
  - (void)failedTransaction:(SKPaymentTransaction *)transaction {
  
      NSLog(@"error code = %ld", transaction.error.code);
  
      // If IAP fails, display an alertView.
      NSString *title = @"Purchase Failed";
      NSString *messageString = @"In-app Purchased failed. Could not contact iTunes store or iTunes login not valid";
  
      if (transaction.error.code != SKErrorPaymentCancelled) {
          UIAlertView *iapFailedAlertView = [[UIAlertView alloc] initWithTitle:title message:messageString delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
          [iapFailedAlertView show];
          iapFailedAlertView = nil;
      }
  
      [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
  }
  </code></pre>
  
  <p>see anything I'm doing wrong?</p>