iPhone - in-App purchase consumable correct approach

前端 未结 3 1600
走了就别回头了
走了就别回头了 2020-12-07 08:57

I have this new app I am creating that will use consumable in-app purchases.

My question is this: how does that work? I mean, imagine the user buys a consumable stuf

3条回答
  •  长情又很酷
    2020-12-07 09:35

    For people who come hare searching for the way to store consumable items locally in iOS, have a look at PDKeychainBindingsController (https://github.com/carlbrown/PDKeychainBindingsController).

    It works like NSUserDefaults and can be used to store the purchased consumable item count in iDevice's keychain (the items stored in keychain do not get removed while deleting the app.).

    Use the code something like below to store and retrieve the value from keychain:

    - (NSUInteger)hintCount {
        PDKeychainBindings *wrapper=[PDKeychainBindings sharedKeychainBindings];
        NSString *valueString = [wrapper objectForKey:@"hintCount"];
        int value = [valueString intValue];
        return value;
    }
    
    - (void)setHintCount:(NSUInteger)starCount {
        PDKeychainBindings *wrapper=[PDKeychainBindings sharedKeychainBindings];
        NSString *valueString = [NSString stringWithFormat:@"%i",starCount];
        [wrapper setObject:valueString forKey:@"hintCount"];
    }
    

提交回复
热议问题