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中 ...
随机推荐
- 由于lightdm.conf 错误无法进入ubuntu 的办法
由于自己向默认登录GNOME桌面,所以修改了lightdm,由于参数错误,结果无法启动桌面? 这是需要进入shell界面: 1.选择cancel ,如果虚拟机下无法点击cancel按钮,可以使用快捷键 ...
- java中this的用法?
2008-07-28 08:10cztx5479 | 分类:JAVA相关 | 浏览4533次 java中this的用法? import java.awt.*; import java.awt.even ...
- matlab图像剪裁命令imcrop()
调用格式: I2=imcrop(I,RECT): X2=imcrop(X,MAP,RECT): RGB2=imcrop(RGB,RECT): 其中,I.X.RGB分别对应灰度图像.索引图像.RGB图像 ...
- JAVA SERVLET专题(下)
HTTP简介 ·WEB浏览器与WEB服务器之间的一问一答的交互过程必须遵守一定的规则,这个规则就是HTTP协议. ·HTTP是hypertext transfer protocol(超文本传输协议)的 ...
- poj3280 区间dp
//Accepted 15880 KB 250 ms #include <cstdio> #include <cstring> #include <iostream> ...
- 解决使用IIS5.0配置的FTP服务器,客户端浏览器访问时无法获取目录列表的问题。
我在windows xp sp3下利用iis构架了FTP服务器,允许且只允许匿名用户登陆.但刚开始配置好后,不管是使用命令行模式还是使用浏览器都发现无法访问. 于是怀疑防火墙屏蔽端口所致,果不其然,在 ...
- CAD系统变量(参数)大全
所谓系统变量就是一些参数,这些参数有些是可以在“选项”或其他对话框中进行设置的,有些这必须通过在命令行输入变量名进行设置,当然对于高手来说,还可以通过二次开发程序来进行控制. CAD有很多的变量,例如 ...
- 认真对待每一道算法题 之 两个排序好的数组寻找的第k个大的数
转载博客:http://www.cnblogs.com/buptLizer/archive/2012/03/31/2427579.html 题目意思:给出两个排好序的数组 ,不妨设为a,b都按升序排列 ...
- UILabel自适应宽度的函数详解
之前用Text Kit写Reader的时候,在分页时要计算一段文本的尺寸大小,之前使用了NSString类的sizeWithFont:constrainedToSize:lineBreakMode:方 ...
- PHP Forms
<html><body><form action="welcome.php" method="post">Name: < ...