When trying to purchase with the iAP the app crashes and shows in Xcode. I bought this code from someone but nobody else complained of an error with iAP on the comments page and I could swear I tested and it worked fine before. I even tried the project fresh and it still is crashing. I'm only a beginner at coding as well so I can do basic things but please be specific Id appreciate it. I don't think it has anything to do with provisions profiles or certificates cause its right in the code. Also its been a while and might sound dumb, but does everything need to be configured in iTunes connect with the same bundle ID and iAP info to work? Ive tried it with everything setup and it still don't work. Regardless, code shouldn't crash. Please take a look, I'll post the screenshots and code.
Most the code from my AppController.mm that has to do with iAP is Here: (Sorry, not sure why it is piecing it weird in code format...I just copied and pasted. So I'm only going to put the error parts)
- (void) openRestore:(NSObject*)prms
{
[[SKPaymentQueue defaultQueue]restoreCompletedTransactions];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
NSArray *myProduct = response.products;
NSLog(@"%@",[[myProduct objectAtIndex:0] productIdentifier]);
SKPayment *newPayment = [SKPayment paymentWithProduct:[myProduct objectAtIndex:0]];
[[SKPaymentQueue defaultQueue] addPayment:newPayment];
}
- (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;
}
}
}