Hi
We already set up the iTunes Connect for promo codes.
There are promocodes that will give you for example (100 gems when you enter this code)
But the user enters the promo code when purchasing the app. the app behaves just as it would if it had been purchased.
1) My question is how can i determined that he purchased the app using promocode?
2) Also how can i restor his transaction that he already used this promo code?
What framework should i used. StoreKit?,SKPaymentQueue?.
Btw i try this code but no luck..
-(void)checkTransactions{
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
#pragma mark - StoreKit Observer
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased: {
/
/
NSLog(@">>>>>>>>> %lu",(unsigned long)transactions.count);
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
}
case SKPaymentTransactionStateFailed: {
/
NSLog(@"There was a problem with your purchase. Please try again later.");
break;
}
case SKPaymentTransactionStateRestored: {
/
NSLog(@"Successfully restored your purchase");
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
}
case SKPaymentTransactionStatePurchasing: {
/
NSLog(@"SKPaymentTransactionStatePurchasing");
break;
}
default:
break;
}
}
}
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
NSMutableArray * purchasedItemIDs = [[NSMutableArray alloc] init];
NSLog(@"received restored transactions: %lu", (unsigned long)queue.transactions.count);
for (SKPaymentTransaction *transaction in queue.transactions)
{
NSLog(@"???? %@",transaction.payment.productIdentifier);
NSString *productID = transaction.payment.productIdentifier;
[purchasedItemIDs addObject:productID];
}
}