Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restore button for in-app purchases error

I got a problem while restoring an in-app purchase in my app

I already applied this lines of codes in my project:

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

but it calls this function

- (void)paymentQueue:(SKPaymentQueue*)queue restoreCompletedTransactionsFailedWithError:(NSError*)error
{
    NSLog(@"error");
}

What must I need to do to avoid getting this error? and call this function:

- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
    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];
    }

}

Thanks in advance guys!

like image 614
SwiftlyNily Avatar asked Dec 11 '25 12:12

SwiftlyNily


2 Answers

I had the same problem while testing from the simulator. Try it on a physical device since in-app purchases are not available on simulator.

like image 164
missaghi Avatar answered Dec 14 '25 02:12

missaghi


From the "In-App Purchase Programming Guide": Store Kit does not operate in iOS Simulator. When running your application in iOS Simulator, Store Kit logs a warning if your application attempts to retrieve the payment queue. Testing the store must be done on actual devices.

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/DevelopingwithStoreKit/DevelopingwithStoreKit.html

like image 37
tkanzakic Avatar answered Dec 14 '25 02:12

tkanzakic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!