ios - How would I use non deprecated API for SKPaymentQueue? -


i using using deprecated api , want update code use non-depcreated code.

so big question how response list?

- (void) buyfeature:(nsstring*) featureid { //    skproduct *myproduct;     if ([skpaymentqueue canmakepayments])     {         skpayment *payment = [skpayment paymentwithproductidentifier:featureid]; //        skpayment *payment = [skpayment paymentwithproduct:myproduct];         [[skpaymentqueue defaultqueue] addpayment:payment];     }     else     {         [[nsnotificationcenter defaultcenter] postnotificationname:@"purchasedone" object:nil];          uialertview *alert = [[uialertview alloc] initwithtitle:@"warning" message:@"you not authorized purchase appstore"                                                        delegate:self cancelbuttontitle:@"ok" otherbuttontitles: nil];         [alert show];         [alert release];     } }  - (void) purchase: (int) productindex {     [self buyfeature: [aryproductids objectatindex: productindex]]; } 

aryproductids defined under (id)init

aryproductids = [[nsmutablearray alloc] initwithobjects: @"iap_100orangedollars",                  @"iap_1",                  @"iap_2",                  @"iap_1month",                  @"iap_3month",                  @"iap_6month",                  @"iap_12month",                  @"iap_1lifetime",                  nil]; 

i not sure use myproduct (type skproduct).

ive seen many examples using nsset instead of nsmutablearray. not sure if need change it

first need acquire product info on of products:

nsset *productstorequest = [nsset setwitharray:aryproductids]; skproductsrequest *request= [[skproductsrequest alloc] initwithproductidentifiers:productstorequest]; request.delegate = self; [request start]; 

you'll delegate callback. might want create dictionary response:

- (void)productsrequest:(skproductsrequest *)request didreceiveresponse:(skproductsresponse *)response {     nsmutabledictionary *dict = [nsmutabledictionary dictionary];     (skproduct *product in response.products)     {         dict[product.productidentifier] = product;     }     self.products = dict; } 

you want @ response , check see if there invalidproductidentifiers well, basic idea.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -