如果想 USER 用特定次數便提示用家比 “錢” 買 完整版 , 可以用呢個方法
本身 APPS 有個叫nsuserdefault 可以儲存資料, 例如APPS 登入資料, 用過幾次等
今次呢個 APPS 如果用家用過一次便會收 nsuserdefault 既 counter +1 , 除左儲 integer , 可以儲 string , 什至 array 都得
係你個 ACTION 個度加入。
int calCounter = [[NSUserDefaults standardUserDefaults] integerForKey:@"counter"];
calCounter +=1;
[[NSUserDefaults standardUserDefaults] setInteger:calCounter forKey:@"counter"];
[[NSUserDefaults standardUserDefaults] synchronize];
calCounter = [[NSUserDefaults standardUserDefaults] integerForKey:@"counter"];
NSLog(@"new counter %d",calCounter);
最後個兩句係比 CONSOLE 睇結果, 加唔加無乜所謂
係每次行 ACTION 前后
加上
calcounter%10 == 0 , 即係每 10 次問一問 , 然后加入一個 FUNCTION
calCounter = [[NSUserDefaults standardUserDefaults] integerForKey:@"counter"];
if ( calCounter%10 == 0 && calCounter >1){
NSString *alertMessage = [NSString stringWithFormat:@"%d times calculation has been made",calCounter];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Go Get Full Version"
message:alertMessage
delegate:self cancelButtonTitle:@"Ignore"
otherButtonTitles:@"Buy Full Version",nil];
[alert show];
[alert release];
}
1 則留言:
唔可以再係 APP 叫人買 FULL VERSION ,
一定要經 IN﹣APP PURCHASE
否則 APP 會被 REJECTED
發佈留言