Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
Add method for incrementing consumables without a purchase
Browse files Browse the repository at this point in the history
  • Loading branch information
warpling committed Jul 27, 2015
1 parent 67619ed commit 7e2729c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions MKStoreKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,19 @@ extern NSString *const kMKStoreKitSubscriptionExpiredNotification;
*/
- (NSNumber *)consumeCredits:(NSNumber *)creditCountToConsume identifiedByConsumableIdentifier:(NSString *)consumableId;

/*!
* @abstract This method updates the available credits (managed by MKStoreKit) for a given consumable
*
* @discussion
* MKStoreKit provides a basic virtual currency manager for your consumables
* This method should only be called if the user earns a credit that doesn't result from a purchase
* A consumable ID is different from its product id, and it is configured in MKStoreKitConfigs.plist file
*
* @seealso
* -availableCreditsForConsumable:
*/
- (NSNumber *)addCreditsWithoutPurchase:(NSNumber *)creditCountToAdd identifiedByConsumableIdentifier:(NSString *)consumableId {

/*!
* @abstract This method sets the default credits (managed by MKStoreKit) for a given consumable
*
Expand Down
8 changes: 8 additions & 0 deletions MKStoreKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ - (NSNumber *)consumeCredits:(NSNumber *)creditCountToConsume identifiedByConsum
return currentConsumableCount;
}

- (NSNumber *)addCreditsWithoutPurchase:(NSNumber *)creditCountToAdd identifiedByConsumableIdentifier:(NSString *)consumableId {
NSNumber *currentConsumableCount = self.purchaseRecord[consumableId];
currentConsumableCount = @([currentConsumableCount doubleValue] + [creditCountToAdd doubleValue]);
self.purchaseRecord[consumableId] = currentConsumableCount;
[self savePurchaseRecord];
return currentConsumableCount;
}

- (void)setDefaultCredits:(NSNumber *)creditCount forConsumableIdentifier:(NSString *)consumableId {
if (self.purchaseRecord[consumableId] == nil) {
self.purchaseRecord[consumableId] = creditCount;
Expand Down

0 comments on commit 7e2729c

Please sign in to comment.