IAP problem
- Get link
- X
- Other Apps
i try put in app purchase in application. tested application in real device , worked sent apple review , rejected. reason nothing happens when purchase button tapped. didnt change code , tested again. nothing happens. transaction status seen canceled. here codes have.
and in log screencode:- (ibaction)removeadstapped { if ([skpaymentqueue canmakepayments]) { nslog(@"user can make payment"); skproductsrequest *prorequest = [[skproductsrequest alloc] initwithproductidentifiers:[nsset setwithobject:kremoveadsproductidentifier]]; prorequest.delegate = (id)self; [prorequest start]; } else{ nslog(@"cant make payment"); uialertview *alert = [[uialertview alloc] initwithtitle:@"warning" message:@"you can't make payment" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil, nil]; [alert show]; } } - (void)productsrequest:(skproductsrequest *)request didreceiveresponse:(skproductsresponse *)response{ skproduct *validproduct = nil; nsuinteger count = [response.products count]; if (count >0) { validproduct = [response.products objectatindex:0]; nslog(@"products available!"); [self purchase:validproduct]; } else if(!validproduct){ nslog(@"no products available"); } } - (void) purchase:(skproduct *)product{ skpayment *payment = [skpayment paymentwithproduct:product]; [[skpaymentqueue defaultqueue] addtransactionobserver:(id)self]; [[skpaymentqueue defaultqueue] addpayment:payment]; } - (void) paymentqueuerestorecompletedtransactionsfinished:(skpaymentqueue *)queue { nslog(@"received restored transactions: %lu", (unsigned long)queue.transactions.count); (skpaymenttransaction *transaction in queue.transactions) { if(skpaymenttransactionstaterestored){ nslog(@"transaction state -> restored"); nsstring *productid = transaction.payment.productidentifier; [self.arrpurchaseditemids addobject:productid]; [[skpaymentqueue defaultqueue] finishtransaction:transaction]; break; } } } - (void)paymentqueue:(skpaymentqueue *)queue updatedtransactions:(nsarray *)transactions{ for(skpaymenttransaction *transaction in transactions){ switch (transaction.transactionstate){ case skpaymenttransactionstatedeferred: break; case skpaymenttransactionstatepurchasing: nslog(@"transaction state -> purchasing"); break; case skpaymenttransactionstatepurchased: [[nsuserdefaults standarduserdefaults] setbool:yes forkey:@"areaddsremoved"]; [[nsuserdefaults standarduserdefaults] synchronize]; [[skpaymentqueue defaultqueue] restorecompletedtransactions]; [[skpaymentqueue defaultqueue] finishtransaction:transaction]; nslog(@"transaction state -> purchased"); break; case skpaymenttransactionstaterestored: nslog(@"transaction state -> restored"); [[skpaymentqueue defaultqueue] finishtransaction:transaction]; break; case skpaymenttransactionstatefailed: if(transaction.error.code != skerrorpaymentcancelled){ nslog(@"transaction state -> cancelled"); } [[skpaymentqueue defaultqueue] finishtransaction:transaction]; break; } } }
what can problem here ?
this not showing actual error, error skerrorpaymentcancelledcode:if(transaction.error.code != skerrorpaymentcancelled){ nslog(@"transaction state -> cancelled"); }
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
- Get link
- X
- Other Apps
Comments
Post a Comment