Question

I have IAP question. Basically, my app needs calculate how many times a user is using a function, and I would like to charge accordingly. I probably going to charge 1 cent or so per usage of the function, so if IAP is $1 minimum, that's credit for 100 usages.

Now my question is that what type of IAP I should choose: consumable, non-consumable, subscription.

Second part of the question is: If the user pays $1 for the IAP, s/he could use the function 100 times. How should I track the usage time and where to temporarily store the usage value? I know I could write/read in/out of a file in the sandbox, would that be secure? The user may use 10 times and quit and come back to continue. I need give the user credit for another 90 usages.

Do I have to go the way that you buy IAP once and enjoy all time. By that way, I have to set IAP price higher and attract much fewer purchases.

Any idea? Thanks!

the code I have seems to have problem. user can re-install and get full initial credits again.

 initialCredit = 500;

 defaults = [NSUserDefaults standardUserDefaults];
 if (![defaults objectForKey:theAppCrediteKey]) {
      [defaults setObject:[NSNumber numberWithFloat:initialCredit]               forKey:theAppCrediteKey];
 }
 readingCredits = [defaults objectForKey:theAppCrediteKey];
 if ([readingCredits floatValue] < 0) {
 readingCredits = [NSNumber numberWithFloat:0];
 }
Was it helpful?

Solution

That's definitely a consumable purchase - if they use up their 100 credits, they can buy another 100 credits for a further $1.

Why not implement a counter in your user preferences - on purchase of the $1 IAP you add 100 credits to the counter, and decrement it each time the function is called?

[Edit] e.g. Here's a quick and hacky solution, assuming everything is happening within the same module, and doesn't check store receipts or anything else.

Make sure the key is available in the standard user defaults:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:@"Credits"])
    [defaults setObject:[NSNumber numberWithInt:0] forKey:@"Credits"];

NSNumber *credits = [defaults objectForKey:@"Credits"];

When the decrement action happens:

credits = [NSNumber numberWithInt:[credits intValue]-1];

or on IAP:

credits = [NSNumber numberWithInt:[credits intValue]+100];

Save the value to the user defaults when appropriate:

[defaults setObject:credits forKey:@"Credits"];
[defaults synchronize];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top