I'm implementing in-app purchase in an iphone application that allows for downloading of a non-trivial amount of data.
Right now, I'm trying to figure out if the Store Kit can tell me if there are any transactions where the purchase is complete, but that have been interrupted by application shutdown.
As far as I can tell the only way to do this is to add an observer to the SKPaymentQueue:
[[SKPaymentQueue defaultQueue] addTransactionObserver:someObject];
and wait for the defaultQueue to call
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
on someObject. Items that are in the interrupted state above show up in the transactions array as SKPaymentTransactionStatePurchased when this method is
My first attempt at solving this problem was to add my observer and then ask for:
[SKPaymentQueue defaultQueue].transactions
开发者_高级运维
and inspect those. This allegedly returns an array of 'pending' transactions, but in my experience doesn't include transactions that are in SKPaymentTransactionStatePurchased.
I was hoping to use the storekit to maintain this state and would love any ideas. Thank you.
I decided that it was impossible to do this using store kit alone so I made a small table in sqlite:
create table purchased_products (
product_identifier text primary key, -- apple store id string
purchased integer not null -- 1 if purchased
);
and when I get the SKPaymentQueue callback indicating that a product has been purchased I add a row to this table.
It's working just fine.
精彩评论