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中 ...
随机推荐
- Repeater 合并单元格
前途页面: <asp:Repeater ID="rptList" runat="server" OnPreRender="rptList_Pre ...
- hadoop 8步走
1.1读取hdfs中的文件.每一行解析成一个<k,v>.每一个键值对调用一次map函数 解析成2个<k,v>,分别是<0, hello you>< ...
- IntelliJ IDEA 12.0
User name:JavaDeveloper Serial number:92547-KY2BB-QZ0S1-PEZCV-HUT8Q-6RYY4
- joinfetch之意义
既然被join的对象早晚都要用到,为什么要先从A表取这边的独享,再根据关联关系取B表中的对象,分两次或者多次进行,增加数据库的负载呢? 为什么不把A表和B表join成一张表,从这个组合表中把要取的对象 ...
- new work
果不其然,还是电子工程师适合我.
- vc设置按钮文字颜色
设置按钮文字颜色使用 CMFCBUTTON即可 在OnInitDialog函数加入如下内容即可 ((CMFCButton*)GetDlgItem(IDC_MFCBUTTON1))->SetTex ...
- hdu 2028
PS:以前对long long型的数据就一直不怎么明白...弄了好久... long long a; scanf("%lld",&a); printf("%lld ...
- php大力力 [018节]如何联系大力力
有事儿就注册博客园,给我发 博客园站内的 短消息呗,唉,没有人联系我呀,啦啦啦,爱我爱我,快点爱我 2015-08-26 php大力力018.如何联系大力力
- LeetCode----Word Ladder 2
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from ...
- BZOJ 1271 秦腾与教学评估
二分. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> ...