SCPStoreKitManager icon indicating copy to clipboard operation
SCPStoreKitManager copied to clipboard

Restore does not works at all

Open avdyushin opened this issue 9 years ago • 2 comments

restoreCompletedTransactions has no delegate methods. Seems to be old version in cocoapods

avdyushin avatar Sep 18 '15 08:09 avdyushin

This can be fixed by custom category

#import <SCPStoreKitManager/SCPStoreKitManager.h>

@interface SCPStoreKitManager (Restore)
-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error;
-(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue;
@end

#import "SCPStoreKitManager+Restore.h"

@interface SCPStoreKitManager ()
@property (nonatomic, copy) PaymentTransactionStateFailed paymentTransactionStateFailedBlock;
@property (nonatomic, copy) PaymentTransactionStateRestored paymentTransactionStateRestoredBlock;
@end

@implementation SCPStoreKitManager (Restore)
-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
{
    NSLog(@"restoreCompletedTransactionsFailedWithError %@", error.localizedDescription);
    self.paymentTransactionStateFailedBlock(queue.transactions);
}

-(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
    NSLog(@"paymentQueueRestoreCompletedTransactionsFinished");
    self.paymentTransactionStateRestoredBlock(queue.transactions);
}

@end

SoundBlaster avatar Nov 25 '15 19:11 SoundBlaster

I had a problem with a "This In-App Purchase Has Aready Been Bought" message but then failing with restoring the item -> http://greensopinion.com/2017/03/22/This-In-App-Purchase-Has-Already-Been-Bought.html

My problem seemed that the a framework was "stealing" the SKPaymentQueue / SKPaymentTransactionObserver events and my app could not restore the item. Calling [[SKPaymentQueue defaultQueue] addTransactionObserver:[SCPStoreKitManager sharedInstance]]; in AppDelegate before adding other frameworks did the job.

o-g-sus avatar Jun 06 '17 13:06 o-g-sus