Saturday 15 June 2013

objective c - obj c in app purchase error -



objective c - obj c in app purchase error -

i made in app purchase code , returns me this:

2014-10-16 23:12:49.130 app[202:9218] bsxpcmessage received error message: connection interrupted 2014-10-16 23:12:53.531 app[202:9200] -[__nscfconstantstring productidentifier]: unrecognized selector sent instance 0xce14c 2014-10-16 23:12:53.533 app[202:9200] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfconstantstring productidentifier]: unrecognized selector sent instance 0xce14c' *** first throw phone call stack: (0x23390f87 0x30d31c77 0x2339637d 0x23394259 0x232c5d68 0x2678cee1 0xcb349 0x2683f977 0x2683f919 0x2682a51d 0x2683f349 0x2683f023 0x26838929 0x2680f195 0x26a82853 0x2680dbd7 0x23357807 0x23356c1b 0x23355299 0x232a2db1 0x232a2bc3 0x2a5d6051 0x2686df01 0xcc815 0x312cdaaf) libc++abi.dylib: terminating uncaught exception of type nsexception (lldb)

it's code:

#import "purchaseviewcontroller.h" @interface purchaseviewcontroller () @property (strong, nonatomic) skproduct *product; @property (strong, nonatomic) purchaseviewcontroller *purchasecontroller; @property (strong, nonatomic) nsstring *productid; @property (strong, nonatomic) iboutlet uitextview *productdescription; - (void)getproductinfo:(uiviewcontroller *)viewcontroller; @end @implementation purchaseviewcontroller - (void)viewdidload { [super viewdidload]; _purchasecontroller = [[purchaseviewcontroller alloc]init]; [[skpaymentqueue defaultqueue] addtransactionobserver:_purchasecontroller]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; } - (ibaction)purchaseitem:(id)sender { _purchasecontroller.productid = @"game"; [self.navigationcontroller pushviewcontroller:_purchasecontroller animated:yes]; [_purchasecontroller getproductinfo: self]; skpayment *payment = [skpayment paymentwithproduct:_product]; [[skpaymentqueue defaultqueue] addpayment:payment]; } -(void)getproductinfo: (purchaseviewcontroller *) viewcontroller { if ([skpaymentqueue canmakepayments]) { skproductsrequest *request = [[skproductsrequest alloc] initwithproductidentifiers: [nsset setwithobject:self.productid]]; request.delegate = self; [request start]; } else _productdescription.text = @"please enable in app purchase in settings"; } #pragma mark - #pragma mark skproductsrequestdelegate -(void)productsrequest:(skproductsrequest *)request didreceiveresponse:(skproductsresponse *)response { nsarray *products = response.products; products = response.invalidproductidentifiers; _product = products[0]; (skproduct *product in products) { nslog(@"product not found: %@", product); } } #pragma mark - #pragma mark skpaymenttransactionobserver -(void)paymentqueue:(skpaymentqueue *)queue updatedtransactions:(nsarray *)transactions { (skpaymenttransaction *transaction in transactions) { switch (transaction.transactionstate) { case skpaymenttransactionstatepurchased: [self unlockfeature]; [[skpaymentqueue defaultqueue] finishtransaction:transaction]; break; case skpaymenttransactionstatefailed: nslog(@"transaction failed"); [[skpaymentqueue defaultqueue] finishtransaction:transaction]; break; default: break; } } } -(void)unlockfeature { nslog(@"bought"); } @end

the error indicates sending productidentifier getter message string. if you're not doing it's skpaymentqueue trying access productidentifier of ... maybe skproduct? however, instead of skproduct (or similar storekit object responds productidentifier), has reference string.

looking @ code (and not knowing crash happens) i'm going guess _product getting set nsstring instead of skproduct. test this, breakpoint code in purchaseitem: before paymentwithproduct: , type po [_product class] in debugger. skproduct?

objective-c in-app-purchase

No comments:

Post a Comment