0

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];
 }
4

1 回答 1

1

这绝对是一个消耗品购买——如果他们用完 100 个积分,他们可以再花 1 美元再购买 100 个积分。

为什么不在你的用户偏好中实现一个计数器——在购买 1 美元的 IAP 时,你向计数器添加 100 个积分,并在每次调用该函数时递减它?

[编辑] 例如,这是一个快速而简单的解决方案,假设一切都发生在同一个模块中,并且不检查商店收据或其他任何东西。

确保密钥在标准用户默认值中可用:

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

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

当递减动作发生时:

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

或在 IAP 上:

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

适当时将值保存为用户默认值:

[defaults setObject:credits forKey:@"Credits"];
[defaults synchronize];
于 2012-10-22T22:58:06.390 回答