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

Asked

Viewed 58 times

3

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 check the product through Licenceinformation. 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: Can you do this on iOS? A friend who has an app posted to the Apple Store says it’s hopeless without first forcing the user to log in to the store.

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

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

1 answer

1


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];
  }
}
  • Vlw William I will test and speak the result.

  • Let me know if it works =D

  • This is William. It worked, but he requested user authentication first. Is there any way to verify the purchase of the product without being asked to log in? As in Windows Phone is not possible to have more than one user, I think that should be why it does not ask for authentication.

  • believe not because the purchase is linked to the user.

  • Blz William. Vlw by force. I will continue researching and if I find something put here. Hugs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.