Reputation: 592
Hey StackOverflow...
My iOS app allows the user to purchase videos as non-consumable iAPs, all the videos are pretty weighty at circa 300mb/650mb each...
Apple require you to implement a restore purchases functionality into your app using StoreKit. This is all fine with me, however, if the user has purchased a few different videos then the sizes could really begin to add up.... I've considered checking if the user is on wifi before this can be done, but to be honest it feels like a workaround not a solution. I'd much rather grab an array of everything the user has downloaded, and let /them/ decide which they want to download now. Is this allowed, or even possible?
Thanks
Ollie
Upvotes: 4
Views: 323
Reputation: 1806
You need handle in this method
-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
{
// Wrote Your code Here
}
Please refer apple doc
Upvotes: 0
Reputation: 957
-(IBAction)goRestore
{
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
//delegate Methods
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
NSLog(@"Access Apple successfully");
NSMutableArray *purchasedItemIDs = [[NSMutableArray alloc] init];
NSLog(@"Received restored transactions: %i", queue.transactions.count);
for (SKPaymentTransaction *transaction in queue.transactions)
{
NSString *productID = transaction.payment.productIdentifier;
[purchasedItemIDs addObject:productID];
NSLog(@"Lan thu %i tra ve ID = %@",[purchasedItemIDs count],productID);
}
//purchasedItemIDs you get all purchase product identifier and compere from your side
}
-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error{
NSLog(@"Error when purchasing: %@",error);
}
Upvotes: 2
Reputation: 13192
Yes, their requirement is that in you user interface you would make difference between already purchased and not purchased goods. For example for the already purchased stuff you can use a status like "Download again already purchased video" and for not yet purchased videos "Buy this video for $99".
Upvotes: 5
Reputation: 8109
u can use SKPaymentQueue's restoreCompletedTransactions
and from the array of SKPaymentTransaction
objects you can use transactionIdentifier
to track the purchased transactions.
Upvotes: 1