应用启动三次弹出评论框

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值