How to check if a product has already been purchased by the user on iOS?

Question:

Guys, when I want to validate if a product of my application (an InApp) has already been purchased by the user, on Windows Phone I just need to verify the product through LicenseInformation. For example:

var license = CurrentApp.LicenseInformation.ProductLicenses["id_do_meu_produto"];
if (!license.IsActive) 
{
  // O usuário ainda não comprou este item
  ...
}

Now the question: Is it possible to do this on iOS? A friend who has an app published on the Apple Store says there's no way out without first forcing the user to log into the store.

How can I check if the user has already paid for an item?

Unfortunately some (few) users are buying the product and then asking Apple for a refund. So they get the product for free.

Answer:

try like this:

- (void) verificaItensComprados {
   [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}//chame essa funçao

//no delegate da funcao
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
  itensCompradosIDs = [[NSMutableArray alloc] init];

  NSLog(@"numero de produtos a ser restabelecido: %i", queue.transactions.count);
  for (SKPaymentTransaction *transaction in queue.transactions)
  {
      NSString *produtoID = transaction.payment.productIdentifier;
      [itensCompradosIDs addObject:produtoID];
  }
}
Scroll to Top