diff --git a/MKSKProduct.m b/MKSKProduct.m index ab6066d..5c179be 100644 --- a/MKSKProduct.m +++ b/MKSKProduct.m @@ -30,7 +30,7 @@ #import "MKSKProduct.h" #if ! __has_feature(objc_arc) -#error MKNetworkKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag +#error MKStoreKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag #endif static void (^onReviewRequestVerificationSucceeded)(); diff --git a/MKSKSubscriptionProduct.m b/MKSKSubscriptionProduct.m index d637c7d..e106366 100644 --- a/MKSKSubscriptionProduct.m +++ b/MKSKSubscriptionProduct.m @@ -32,7 +32,7 @@ #import "MKSKSubscriptionProduct.h" #import "NSData+Base64.h" #if ! __has_feature(objc_arc) -#error MKNetworkKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag +#error MKStoreKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag #endif @implementation MKSKSubscriptionProduct diff --git a/MKStoreManager.h b/MKStoreManager.h index a5e8908..5a3fcc2 100644 --- a/MKStoreManager.h +++ b/MKStoreManager.h @@ -76,6 +76,7 @@ //for testing proposes you can use this method to remove all the saved keychain data (saved purchases, etc.) - (BOOL) removeAllKeychainData; ++(id) receiptForKey:(NSString*) key; +(void) setObject:(id) object forKey:(NSString*) key; +(NSNumber*) numberForKey:(NSString*) key; diff --git a/MKStoreManager.m b/MKStoreManager.m index 3d77856..be849a0 100644 --- a/MKStoreManager.m +++ b/MKStoreManager.m @@ -38,7 +38,7 @@ #import "MKSKProduct.h" #import "NSData+Base64.h" #if ! __has_feature(objc_arc) -#error MKNetworkKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag +#error MKStoreKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag #endif @interface MKStoreManager () //private methods and properties @@ -57,7 +57,7 @@ @interface MKStoreManager () //private methods and properties - (void) requestProductData; - (void) startVerifyingSubscriptionReceipts; --(void) rememberPurchaseOfProduct:(NSString*) productIdentifier; +-(void) rememberPurchaseOfProduct:(NSString*) productIdentifier withReceipt:(NSData*) receiptData; -(void) addToQueue:(NSString*) productId; @end @@ -151,6 +151,15 @@ +(void) setObject:(id) object forKey:(NSString*) key } } ++(id) receiptForKey:(NSString*) key { + + NSData *receipt = [MKStoreManager objectForKey:key]; + if(!receipt) + receipt = [MKStoreManager objectForKey:[NSString stringWithFormat:@"%@-receipt", key]]; + + return receipt; +} + +(id) objectForKey:(NSString*) key { NSError *error = nil; @@ -589,7 +598,7 @@ -(void) provideContent: (NSString*) productIdentifier [thisProduct verifyReceiptOnComplete:^ { - [self rememberPurchaseOfProduct:productIdentifier]; + [self rememberPurchaseOfProduct:productIdentifier withReceipt:receiptData]; } onError:^(NSError* error) { @@ -605,7 +614,7 @@ -(void) provideContent: (NSString*) productIdentifier } else { - [self rememberPurchaseOfProduct:productIdentifier]; + [self rememberPurchaseOfProduct:productIdentifier withReceipt:receiptData]; if(self.onTransactionCompleted) self.onTransactionCompleted(productIdentifier, receiptData); } @@ -613,7 +622,7 @@ -(void) provideContent: (NSString*) productIdentifier } --(void) rememberPurchaseOfProduct:(NSString*) productIdentifier +-(void) rememberPurchaseOfProduct:(NSString*) productIdentifier withReceipt:(NSData*) receiptData { NSDictionary *allConsumables = [[self storeKitItems] objectForKey:@"Consumables"]; if([[allConsumables allKeys] containsObject:productIdentifier]) @@ -631,6 +640,8 @@ -(void) rememberPurchaseOfProduct:(NSString*) productIdentifier { [MKStoreManager setObject:[NSNumber numberWithBool:YES] forKey:productIdentifier]; } + + [MKStoreManager setObject:receiptData forKey:[NSString stringWithFormat:@"%@-receipt", productIdentifier]]; } - (void) transactionCanceled: (SKPaymentTransaction *)transaction diff --git a/MKStoreObserver.m b/MKStoreObserver.m index 977129b..4895614 100644 --- a/MKStoreObserver.m +++ b/MKStoreObserver.m @@ -18,7 +18,7 @@ #import "MKStoreObserver.h" #import "MKStoreManager.h" #if ! __has_feature(objc_arc) -#error MKNetworkKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag +#error MKStoreKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag #endif @interface MKStoreManager (InternalMethods)