IOS中打开应用实现检查更新的功能
//检查更新页面
- (void)Renew{
NSDictionary *infoDic = [[NSBundle mainBundle]infoDictionary];
NSString *version = [infoDic valueForKey:@"CFBundleShortVersionString"];
NSString *ipstr = [NSObject deviceIPAdress];
NSString *paramIp = ipstr;
NSTimeInterval time = [[NSDate date]timeIntervalSince1970];
long i = time;
NSString *paramTime = [NSString stringWithFormat:@"%ld",i];
NSString *signstr = [NSString stringWithFormat:@"%@%@%@%@",paramTime,paramIp,@"phone_ios",@"d556bd3337cd909b49eb5e33f46ad65c"];
NSString *md5str = [signstr MD5Hash];
NSString *mdstr = [md5str lowercaseString];
NSString *sign = mdstr;
NSString *key = @"phone_ios";
NSDictionary *param = @{
@"type" : @2,
@"version" : version
};
NSDictionary *dict = @{
@"paramTime" : paramTime,
@"paramIp" : paramIp,
@"sign":sign,
@"key" : key,
@"param":param
};
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
[manager POST:RenewUrl parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *resultDic = responseObject[@"result"];
_upgradeUrl = resultDic[@"upgradeUrl"];
_force = resultDic[@"isForce"];
NSLog(@"_force--------%@",_force);
NSLog(@"%@",resultDic);
if ([resultDic[@"isForce"]compare:@0] !=NSOrderedSame) {
UIAlertView *isForceView = [[UIAlertView alloc]initWithTitle:@"特别提示" message:@"发现新版本" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"下载", nil];
[isForceView show];
}else if ([resultDic[@"version"]compare:version] != NSOrderedSame) {
UIAlertView *resultView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"发现新版本" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"下载", nil];
[resultView show];
}else{
return ;
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
UIAlertView *errorView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"网络有问题" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[errorView show];
NSLog(@"%@",error);
}];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if ([_force compare:@1 ]!=NSOrderedSame) {
if (buttonIndex==1) {
[self startDownLoad];
// [[UIApplication sharedApplication]openURL:[NSURL URLWithString:_upgradeUrl]];
}
}else if ([_force compare:@0] !=NSOrderedSame){
if ( buttonIndex == 1) {
// [[UIApplication sharedApplication]openURL:[NSURL URLWithString:_upgradeUrl]];
[self startDownLoad];
}else if (buttonIndex == 0){
exit(0);
}
}
}
- (void) startDownLoad{
NSURL *url = [NSURL URLWithString:_upgradeUrl];
// NSLog(@"url-------%@",url);
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLConnection *connect = [NSURLConnection connectionWithRequest:request delegate:self];
[connect start];
}
IOS中打开应用实现检查更新的功能的更多相关文章
- iOS开发中打开本地应用、打开appStore应用、给app评分功能实现
app开发中,通常会有邀请用户给app打分的功能.而在iOS中,正式应用都是通过appStore 下载的,因此给app 打分也只能在 appStore中.因此,需要从应用跳转到appStore.方法是 ...
- iOS评分功能、APP中打开其他应用程序
1.评分功能 iOS中评分支持功能开发非常简单. NSString *str = [NSString stringWithFormat: @"itms-apps://itunes.apple ...
- IOS中调用系统的电话、短信、邮件、浏览功能
iOS开发系列--通讯录.蓝牙.内购.GameCenter.iCloud.Passbook系统服务开发汇总 2015-01-13 09:16 by KenshinCui, 26990 阅读, 35 评 ...
- 【IOS】在SDK中打开其他接入应用的解决方案
在SDK中打开其他接入应用的解决方案 一直以来,在iOS的开发中,在程序中打开另外一个应用是不允许.后来有正义之士用class-dump在私有API中找到了这样的功能.那就是使用UIApplica ...
- 在IOS应用中打开另外一个应用的解决方案
最近要在IOS中实现一个应用启动另外一个应用的功能,搜了一些资料,使用UIApplication的openURL:的方法就能实现,现在整理和大家分享一下! 注册自定义URL协议 首先被启动的应用需要向 ...
- iOS中打电话、打开网址、发邮件、发短信等
常用小功能 小功能简介 iOS中的很多小功能都是非常简单的,几行代码就搞定了,比如打电话.打开网址.发邮件.发短信等 打电话-方法1 最简单最直接的方式:直接跳到拨号界面 NSURL *url = [ ...
- 如何在ios中集成微信登录功能
在ios中集成微信的登录功能有两种方法 1 用微信原生的api来做,这样做的好处就是轻量级,程序负重小,在Build Settings 中这样设置 然后设置 友盟的设置同上,但是要注意,加入你需要的所 ...
- 浏览器中打开IOS应用并传参
原创文章,转载请注明 开发中遇到这么一个问题,就是动态地指定联接服务器地址,或其它数据.如果是其它数据还好说一些,可以通过在服务器上获得的方式来弄.但如果服务器地址都需要动态指定的话.那就得另想办法了 ...
- 利用openURL,在IOS应用中打开另外一个应用
在IOS中,实现一个应用启动另外一个应用,使用UIApplication的openURL:方法就可实现,这里以test跳到test02为例.(需要先创建这两个工程) 注册自定义URL协议(在test中 ...
随机推荐
- Linux Lab and project latest
samba : start your samba service netlogon syslog vi /usr/local/samba vi /usr/samba/etc/smb.conf smbc ...
- C# 对MongoDB 进行增删改查的简单操作 (转)
运用到的MongoDB支持的C#驱动,当前版本为1.6.0 下载地址:https://github.com/mongodb/mongo-csharp-driver/downloads 1,连接数据库 ...
- java,android获取系统当前时间
SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss ");Date curDate = ...
- Apache目录结构(一)
一.Apache 目录结构 bin: 该目录用于存放apache常用的命令,比如httpd cig-bin:该目录存放linux下的常用命令 .sh conf:存放配置文件httpd.conf,在ht ...
- (转)SQLite数据库增删改查操作
原文:http://www.cnblogs.com/linjiqin/archive/2011/05/26/2059182.html SQLite数据库增删改查操作 一.使用嵌入式关系型SQLite数 ...
- linux上安装apache
1 安装aprtar -zxvf apr-1.4.2.tar.gz cd apr-1.4.2.tar.gz ./configure --prefix=/usr/local/aprmake & ...
- (spring-第14回【IoC基础篇】)国际化信息
国际化又称为本地化. 当你把手机的language由中文切换到英文时,你的微信也相应改用英语,这就是i18n国际化.一般来说,应用软件提供一套不同语言的资源文件,放到特定目录中,应用根据不同语言的操作 ...
- Unity3d各平台资源路径文件夹
之前一直是PC项目,公司终于考虑移动平台了,但是试验了几把,感觉移动平台资源管理路径还是有很多隐藏的注意事项. 比如在PC上可以做到随便读写,但是在移动平台就涉及到权限问题. 看到小伙伴的总结,还是要 ...
- cookie 作用域
在http://xiaoyou-game.com/user/login方法中设置cookie: setcookie('username',$username,time()+3600,'/user/', ...
- hdu 3635
http://acm.hdu.edu.cn/showproblem.php?pid=3635 1-n个城市,对应放着编号1-n的龙珠. 两种操作 T A B 把编号A的龙珠所在城市内的全部龙珠放到有编 ...