美文网首页
检查版本并去app store更新app

检查版本并去app store更新app

作者: 小y想吃糖 | 来源:发表于2019-07-02 15:03 被阅读0次

检查应用

- (void)___checkVersion {

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

        NSString *string = [NSString stringWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/lookup?id=%@",k_app_store_app_id]] encoding:NSUTF8StringEncoding error:nil];

        NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];

        if(![dataisKindOfClass:[NSDataclass]] || !data) {

            return;

        }

        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data  options:NSJSONReadingMutableLeaves error:nil];

        /*

         "resultCount":0,

         "results": []

         */

        //获得上线版本号

        NSString *newVersion = [[[dic objectForKey:@"results"] firstObject] objectForKey:@"version"];

        NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];

        if(![newVersionisEqualToString:currentVersion]) {

            [self ___showTipForVersion];

        }

    });

    [self ___jumpToAppStore];

}

- (void)___showTipForVersion {

}

- (void)___jumpToAppStore {

    NSString *urlStr = [[NSString alloc] initWithFormat:@"https://itunes.apple.com/lookup?id=%@",k_app_store_app_id];

    NSURL* url = [NSURLURLWithString:urlStr];

    [[UIApplication sharedApplication] openURL:url];

}

相关文章

网友评论

      本文标题:检查版本并去app store更新app

      本文链接:https://www.haomeiwen.com/subject/saxwtctx.html