SCPStoreKitManager
SCPStoreKitManager copied to clipboard
Restore does not works at all
restoreCompletedTransactions
has no delegate methods.
Seems to be old version in cocoapods
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
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.