#pragma mark - 启动三次弹出评论框
-(void)getDeviceRunTime
{
NSArray * paths =NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSString *path =[paths objectAtIndex:0];
NSString * fileName =[path stringByAppendingString:@"ReviewStateList.plist"];
NSFileManager *fm=[NSFileManager defaultManager];
if (![fm fileExistsAtPath:fileName]) {
[fm createFileAtPath:fileName contents:nil attributes:nil];
NSDictionary *dic =[NSDictionary
dictionaryWithObjectsAndKeys:@"No",@"isRightNow",@"No",@"isRejected",@"0",@"later", nil];
[dic writeToFile:fileName atomically:YES];
}
NSMutableDictionary *plistData =[[NSMutableDictionary alloc]initWithContentsOfFile:fileName];
int deviceRunTime =[[plistData objectForKey:@"later"]intValue];
deviceRunTime +=1;
NSLog(@"%d",deviceRunTime);
if (deviceRunTime%3==0) {
if ([[plistData objectForKey:@"isRightNow"]isEqualToString:@"Yes"]||
[[plistData objectForKey:@"isRejected"]isEqualToString:@"Yes"]) {
NSLog(@"已评价过或者拒绝过评价");
}
else {
[reviewAlert show];
}
}
[plistData setObject:[NSString stringWithFormat:@"%d",deviceRunTime] forKey:@"later"];
[plistData writeToFile:fileName atomically:YES];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSArray * paths=NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSString *path=[paths objectAtIndex:0];
NSString * fileName =[path stringByAppendingString:@"ReviewStateList.plist"];
NSMutableDictionary * plistData =[[NSMutableDictionary alloc]initWithContentsOfFile:fileName];
if (buttonIndex==0) {
NSString * appURL =[NSString stringWithFormat:@"https://itunes.apple.com/jp/app/id673107727?mt=8"];
[plistData setObject:@"Yes" forKey:@"isRightNow"];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:appURL]];
}
if (buttonIndex==1) {
[plistData setObject:@"Yes" forKey:@"isRejected"];
}
[plistData writeToFile:fileName atomically:YES];
}
应用启动三次弹出评论框
最新推荐文章于 2022-10-25 10:53:36 发布