Hello everyone, I'n an italian developer, so excuse me for my English.
I just added one in-app purchase to my app.
When a user click on the "purchase" button and the transaction ends, the "purchase" button is replaced by another button to access to the new features.
But everytime I come back to that page or I close and open again the app, there is again the "purchase" button.
How can I do to have always the new button if the user has purchased the new contents?
Here is my code:
Code:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(myaction)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"mytitle" forState:UIControlStateNormal];
button.frame = CGRectMake(156.0, 248.0, 129.0, 36.0);
[self.view addSubview:button];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
NSLog(@"Errorr");
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
}
}