Skip to content

Commit ed1d14a

Browse files
committed
add 'removeTransactionsForProductIdentifier' to RMStoreUserDefaultsPersistence robotmedia#175
1 parent f2206e4 commit ed1d14a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

RMStore/Optional/RMStoreUserDefaultsPersistence.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
*/
3535
- (void)removeTransactions;
3636

37+
/** Remove transactions from user defaults via specific ProductIdentifier.
38+
*/
39+
- (void)removeTransactionsForProductIdentifier:(NSString *)productIdentifier;
40+
3741
/** Consume the given product if available. Intended for consumable products.
3842
@param productIdentifier Identifier of the product to be consumed.
3943
@return YES if the product was consumed, NO otherwise.

RMStore/Optional/RMStoreUserDefaultsPersistence.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ - (void)removeTransactions
5353
[defaults synchronize];
5454
}
5555

56+
- (void)removeTransactionsForProductIdentifier:(NSString *)productIdentifier{
57+
NSUserDefaults *defaults = [self userDefaults];
58+
NSDictionary *purchases = [defaults objectForKey:RMStoreTransactionsUserDefaultsKey] ? : @{};
59+
NSMutableDictionary *updatedPurchases = [NSMutableDictionary dictionaryWithDictionary:purchases];
60+
[updatedPurchases removeObjectForKey:productIdentifier];
61+
[defaults setObject:updatedPurchases forKey:RMStoreTransactionsUserDefaultsKey];
62+
[defaults synchronize];
63+
}
64+
5665
- (BOOL)consumeProductOfIdentifier:(NSString*)productIdentifier
5766
{
5867
NSUserDefaults *defaults = [self userDefaults];

0 commit comments

Comments
 (0)