I\'m using Ray Wenderlich tutorial to create IAP (http://www.raywenderlich.com/23266/) , everything works well, but I don\'t want to use table view on my app, I want to use
If you are done with all the connection work and adding framework below code will work for sure:
- (void) requestProductData
{
if(countphotoval==2)
{
phonetext.text=@"";
countrycode.text=@"";
nametext.text=@"";
Emailtext.text=@"";
photocounter=0;
image1.image=[UIImage imageNamed:@"image-box.png"];
image2.image=[UIImage imageNamed:@"image-box.png"];
labelimage.text=@"Image";
addbuttonforpicker.userInteractionEnabled=true;
addbuttonforpicker2.userInteractionEnabled=false;
countphotoval=0;
}
request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: @"object of inapp purchase"]];
request.delegate = self;
[request start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *myProduct = response.products;
// populate UI
}
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
NSLog(@"transaction array-->%@",transaction.description);
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
// show wait view here
//statusLabel.text = @"Processing...";
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
[NSThread detachNewThreadSelector:@selector(startActivityindicatore) toTarget:self withObject:nil];
[self fordataupload];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
NSLog(@"Error payment cancelled");
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Sorry" message:@"Please provide correct Userid and Password" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[alert show];
[alert release];
// [self dismissModalViewControllerAnimated:YES];
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// remove wait view here
// statusLabel.text = @"Purchase Error!";
break;
default:
break;
}
}
}
- (void) failedTransaction: (SKPaymentTransaction *)transaction
{
if (transaction.error.code != SKErrorPaymentCancelled)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops!" message:@"Something has went wrong" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
- (void) restoreTransaction: (SKPaymentTransaction *)transaction
{
//If you want to save the transaction
// [self recordTransaction: transaction];
//Provide the new content
// [self provideContent: transaction.originalTransaction.payment.productIdentifier];
//Finish the transaction
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
- (void) completeTransaction: (SKPaymentTransaction *)transaction
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Congrats!!" message:@"Your Transaction Is Completed" delegate:self cancelButtonTitle:@"Thanx!" otherButtonTitles:nil];
[alert show];
[alert release];
//If you want to save the transaction
// [self recordTransaction: transaction];
//Provide the new content
//[self provideContent: transaction.payment.productIdentifier];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
-(void)requestDidFinish:(SKRequest *)request1
{
[self stopActivityindicatore];
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"VirtualBinocularsContest1"];
NSLog(@"quality --->%d",payment.quantity);
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
[request release];
}
Please notify if it works for you..:)