美文网首页
获取新版本,去appStore下载

获取新版本,去appStore下载

作者: 牛1688 | 来源:发表于2017-01-19 12:13 被阅读0次

    ==================获取新版本,去appStore下载===================

    #define SHAREURL @"https://itunes.apple.com/cn/app/liang-pin-gou-wu/id1142121819?mt=8"

    //获取本地版本

    -(NSString*)getAPPVerson{

    NSString* version = [[[NSBundlemainBundle]infoDictionary]objectForKey:@"CFBundleShortVersionString"];

    returnversion;

    }

    //获取服武器版本

    -(void)getServerVerson{

    NSDictionary* paraDict =@{};

    //拼接参数.获取版本号

    NSDictionary* postDict = [URLPackedurlFormatWithDict:paraDictA:@"verson"C:@"shops"];

    [FuncationpostWithURL:BASEURLparaments:postDictsuccess:^(idresponseObject) {

    //判断是否有新版本

    //  if

    (![responseObject[@"verson"] isEqualToString:[self getAPPVerson]])

    if(1)

    {

    //弹出警示控制器

    UIAlertController* alert = [UIAlertControlleralertControllerWithTitle:@"有新版本更新"message:nilpreferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction* action = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];

    UIAlertAction* action2 = [UIAlertActionactionWithTitle:@"去App

    Store更新"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction) {

    [[UIApplicationsharedApplication]openURL:[NSURLURLWithString:SHAREURL]];

    }];

    [alertaddAction:action];

    [alertaddAction:action2];

    [selfpresentViewController:alertanimated:YEScompletion:nil];

    }

    }failure:^(iderror) {

    //失败了再次下载版本

    [selfgetServerVerson];

    }];

    }

    相关文章

      网友评论

          本文标题:获取新版本,去appStore下载

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