From 1c89b1a3967acbb57179cc4fbd67a4e50113e312 Mon Sep 17 00:00:00 2001 From: metasmile Date: Thu, 28 Jan 2016 17:41:04 +0900 Subject: [PATCH 1/2] add a method 'removeTransactionsForProductIdentifier' to RMStoreUserDefaultsPersistence --- RMStore/Optional/RMStoreUserDefaultsPersistence.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RMStore/Optional/RMStoreUserDefaultsPersistence.m b/RMStore/Optional/RMStoreUserDefaultsPersistence.m index 9faca374..833257be 100644 --- a/RMStore/Optional/RMStoreUserDefaultsPersistence.m +++ b/RMStore/Optional/RMStoreUserDefaultsPersistence.m @@ -53,6 +53,15 @@ - (void)removeTransactions [defaults synchronize]; } +- (void)removeTransactionsForProductIdentifier:(NSString *)productIdentifier{ + NSUserDefaults *defaults = [self userDefaults]; + NSDictionary *purchases = [defaults objectForKey:RMStoreTransactionsUserDefaultsKey] ? : @{}; + NSMutableDictionary *updatedPurchases = [NSMutableDictionary dictionaryWithDictionary:purchases]; + [updatedPurchases removeObjectForKey:productIdentifier]; + [defaults setObject:updatedPurchases forKey:RMStoreTransactionsUserDefaultsKey]; + [defaults synchronize]; +} + - (BOOL)consumeProductOfIdentifier:(NSString*)productIdentifier { NSUserDefaults *defaults = [self userDefaults]; From fe585cf68d0492db0fff19c68509dbd37e98c44f Mon Sep 17 00:00:00 2001 From: metasmile Date: Thu, 28 Jan 2016 17:41:56 +0900 Subject: [PATCH 2/2] add a method 'removeTransactionsForProductIdentifier' to RMStoreUserDefaultsPersistence --- RMStore/Optional/RMStoreUserDefaultsPersistence.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RMStore/Optional/RMStoreUserDefaultsPersistence.h b/RMStore/Optional/RMStoreUserDefaultsPersistence.h index 45f1fa0d..b8fdd92a 100644 --- a/RMStore/Optional/RMStoreUserDefaultsPersistence.h +++ b/RMStore/Optional/RMStoreUserDefaultsPersistence.h @@ -30,6 +30,10 @@ */ - (void)removeTransactions; +/** Remove transactions from user defaults via specific ProductIdentifier. + */ +- (void)removeTransactionsForProductIdentifier:(NSString *)productIdentifier; + /** Consume the given product if available. Intended for consumable products. @param productIdentifier Identifier of the product to be consumed. @return YES if the product was consumed, NO otherwise. @@ -78,4 +82,4 @@ */ - (RMStoreTransaction*)transactionWithData:(NSData*)data; -@end \ No newline at end of file +@end