ios 过期检测

在该方法的起始插入以下代码:

-(void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

dispatch_async(dispatch_queue_create("APP_EXPIRE_KILL", 0), ^{
    // 检查程序是否过期
    NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MMM d yyyy"];
    [formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]];
    NSDate *expiresDate = [formatter dateFromString:[NSString stringWithFormat:@"%s", __DATE__]];
 
    // 一周过期
    if (now - [expiresDate timeIntervalSince1970] >= 7*24*3600) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"您使用的程序是测试版本,目前已经过期,请更新到最新版本"
                                                        message:nil
                                                       delegate:self
                                              cancelButtonTitle:@"确定"
                                              otherButtonTitles:nil];
        [alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
 
        sleep(10);
        kill(getpid(), 9);
    }
});
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容