objective c - How to get List of Only Purchased Product Ids fron inApp in ios? -
i having app in have 5 non consumable in app purchases.
on every single in app purchase update db images.
there 5 packages 5 non consumable in app purchases.
now there restore purchase functionality non consumable in app purchase.
there single restore button in app. how identify product has being purchased?
i use following code restoring in app purchase. doesn't update db because doesn't know products purchased.
if ([transaction.payment.productidentifier isequaltostring:@"pack1"]) { if ([[nsuserdefaults standarduserdefaults] boolforkey:@"haslaunchedp1once"]) { // app launched nslog(@"launching secondtime"); } else { [[nsuserdefaults standarduserdefaults] setbool:yes forkey:@"haslaunchedp1once"]; nslog(@"launching first time"); requesttext= @"animal"; [self makequeryforupdate]; [self getdata]; } } else if ([transaction.payment.productidentifier isequaltostring:@"pack2"]) { if ([[nsuserdefaults standarduserdefaults] boolforkey:@"haslaunchedp2once"]) { // app launched nslog(@"launching secondtime"); } else { [[nsuserdefaults standarduserdefaults] setbool:yes forkey:@"haslaunchedp2once"]; nslog(@"launching first time"); requesttext= @"celebrity"; [self makequeryforupdate]; [self getdata]; } } else if ([transaction.payment.productidentifier isequaltostring:@"pack3"]) { if ([[nsuserdefaults standarduserdefaults] boolforkey:@"haslaunchedp3once"]) { // app launched nslog(@"launching secondtime"); } else { [[nsuserdefaults standarduserdefaults] setbool:yes forkey:@"haslaunchedp3once"]; nslog(@"launching first time"); requesttext= @"nature"; [self makequeryforupdate]; [self getdata]; } }
how list of purchased product ids?
any appreciated...
you can restore purchases using :
[[skpaymentqueue defaultqueue] restorecompletedtransactions];
then skpaymenttransactionobserver call its
- (void)paymentqueue:(skpaymentqueue *)queue updatedtransactions:(nsarray *)transactions
with skpaymenttransactionstatepurchased transaction state. can see returns array transactions.
can single transaction using,
for (skpaymenttransaction * transaction in transactions) { nslog(@"purchased indentifier : %@", transaction.payment.productidentifier); }
this print out identifiers user have purchased. can set nsuserdefaults regarding these values
Comments
Post a Comment