IOS开发 版本提醒
来源:互联网 发布:是以知其将败 编辑:程序博客网 时间:2024/05/21 11:08
- (void)versionUpdate{
//获得当前发布的版本
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
//耗时的操作---获取某个应用在AppStore上的信息,更改id就行
NSString *string = [NSStringstringWithContentsOfURL:[NSURLURLWithString:@"http://itunes.apple.com/lookup?id=你的APP的id"]
encoding:NSUTF8StringEncodingerror:nil];
NSData *data = [stringdataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *dic = [NSJSONSerializationJSONObjectWithData:dataoptions:NSJSONReadingMutableLeaveserror:nil];
//获得上线版本号
NSString *version = [[[dicobjectForKey:@"results"]firstObject]objectForKey:@"version"];
NSString *updateInfo = [[[dicobjectForKey:@"results"]firstObject]objectForKey:@"releaseNotes"];
//获得当前版本
NSString *currentVersion = [[[NSBundlemainBundle]infoDictionary]objectForKey:@"CFBundleShortVersionString"];
dispatch_async(dispatch_get_main_queue(), ^{
//更新界面
if ( version &&![versionisEqualToString:currentVersion]) {
//有新版本
NSString *message = [NSStringstringWithFormat:@"有新版本发布啦!\n%@",updateInfo];
UIAlertView *alertView = [[UIAlertViewalloc]initWithTitle:@"温馨提示"message:messagedelegate:selfcancelButtonTitle:@"忽略"otherButtonTitles:@"前往更新",nil];
//此种写法文字会居中显示,这样视觉效果很不好,下列demo中已经解决将alertview上的文字具有显示 先关文章链接http://blog.csdn.net/bddzzw/article/details/52169261
[alertViewshow];
}else{
//已是最高版本
NSLog(@"已经是最高版本");
}
});
});
}
/*根据被点击按钮的索引处理点击事件--当被按钮被点击了这里做出一个反馈*/
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex ==1) {
NSString *url =@"你的APP在APPstore的网址";//
https://itunes.apple.com/cn/app/qq/id444934666?mt=8 QQ在APPstore的网址
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:url]];
}
}
//这样还是不够的你应该在网络解析的时候让后台接口返回一个BOOL字段,在APP审核的时候根据字段提示不让提醒更新(因为苹果在审核的时候您的应用提醒更新版本的话会被驳回的),上线之后让后台更改字段在提醒更新最新版本
//此处为另一种版本比较的方法可以移到上边自行使用,用这种方法的好处是讲版本号转为数字比较大小更加智能且避开后台设置bool值
-(NSInteger )getVersionNumber:(NSString *)versionStr
{
NSArray * versionAry=[versionStr componentsSeparatedByString:@"."];
NSString * newVersion;
for (int i=0;i< versionAry.count; i++) {
if (i==0) {
newVersion=[versionAry objectAtIndex:i];
}else
{
newVersion=[NSString stringWithFormat:@"%@%@",newVersion,[versionAry objectAtIndex:i]];
}
}
return [newVersion integerValue];
}
*/Demo下载地址:http://download.csdn.net/detail/bddzzw/9599669
- IOS开发 版本提醒
- iOS开发 版本更新提醒
- iOS开发 app版本更新, 提醒
- iOS 开发:应用内实现 更新提醒
- iOS开发 - UIAlertController 弹框提醒
- iOS应用版本更新(自动提醒用户更新代码)
- IOS应用版本更新(自动提醒用户)
- iOS应用版本更新(自动提醒用户)
- iOS开发,版本更新
- ios 提醒功能开发(应用后台运行消息提醒推送)
- iOS开发学习之#提醒处理#(1)响应提醒视图
- iOS 判断版本是否升级,若是有新的版本,提醒升级
- iOS 开发 初级:应用内实现 更新提醒
- Ios开发中UILocalNotification实现本地通知实现提醒功能
- iOS 开发 初级:应用内实现 更新提醒
- iOS开发中短信提醒功能详解步骤
- iOS开发 UILocalNotification 本地通知实现提醒功能
- iOS开发 UILocalNotification 本地通知实现提醒功能
- Android Support Library 之 夜间模式
- (LeetCode)Counting Bits -- 求二进制中1的个数
- screen
- UVA 621-Secret Research
- 初学IOSUI基础第二天demo1,九宫格纯代码版本,有GIF,有源文件
- IOS开发 版本提醒
- win10和ubuntu双系统启动
- Weird Shader Problem On OpenGLES 3.0
- 【知识】太阳能板行业生产加工步骤(超详细)
- 专访格灵深瞳CTO赵勇:为" 计算机视觉" 赋予智慧的光芒
- Eclipse中使用SVN
- javOSize:新一代java分析工具
- 多选删除和tableView折叠
- Android Video 相关操作更新中