自己整理的ios app实现自动升级

简介: <p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; line-height:26px"> <span style="color:rgb(255,102,102)">主要是写cordova插件</span><b

主要是写cordova插件

<!---------------------------CheckUpdate.h文件----------------------------------------->

#import <Cordova/CDVPlugin.h>


@interface CheckUpdate : CDVPlugin{
    NSString *trackViewUrl;
}

@property (nonatomic,retain) NSString *trackViewUrl;
- (void)checkUpdate:(NSMutableArray*)arguments withDict:(NSDictionary*)options;

@end


<!---------------------------CheckUpdate.m文件----------------------------------------->

#import "CheckUpdate.h"

@implementation CheckUpdate
@synthesize trackViewUrl;

- (void)checkUpdate:(NSMutableArray*)arguments withDict:(NSDictionary*)options{
    
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    NSString *nowVersion = [infoDict objectForKey:@"CFBundleVersion"];
    
    NSError *error;
    NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/lookup?id=739680648"];
    NSURLRequest *request= [NSURLRequest requestWithURL:url];
    NSData *response=[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSDictionary *dict=  [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];

    NSArray *res= [dict objectForKey:@"results"];
    if([res count]){
        NSDictionary *resDict= [res objectAtIndex:0];
        NSString *newVersion = [resDict objectForKey:@"version"];
        self.trackViewUrl=[resDict objectForKey:@"trackViewUrl"];
        
        if([nowVersion isEqualToString:newVersion]==NO)
        {
            NSString *message=[[NSString alloc] initWithFormat:@"当前版本为%@,最新版本为%@", nowVersion, newVersion];
            UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"检测版本更新" message:message   delegate:self     cancelButtonTitle:@"取消" otherButtonTitles:@"更新", nil ];
            [alert show];
            [alert release];
        }else{
            UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"检测版本更新" message:@"已经是最新版本了" delegate:self     cancelButtonTitle:@"取消" otherButtonTitles:nil];
            [alert show];
            [alert release];
        }
    }
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if(buttonIndex == 1){
        NSURL *url= [NSURL URLWithString: self.trackViewUrl];
        [[UIApplication sharedApplication] openURL:url];
        [url release];
    }
}


@end

目录
相关文章
|
1月前
|
人工智能 自然语言处理 云计算
iOS迎来AI升级:揭秘Apple全新“智能”系统
iOS迎来AI升级:揭秘Apple全新“智能”系统
iOS迎来AI升级:揭秘Apple全新“智能”系统
|
1月前
|
编解码 iOS开发
IOS上架APP Store时预览图尺寸
IOS上架APP Store时预览图尺寸
101 3
|
1月前
|
iOS开发
App备案与iOS云管理式证书 ,公钥及证书SHA-1指纹的获取方法
App备案与iOS云管理式证书 ,公钥及证书SHA-1指纹的获取方法
94 0
App备案与iOS云管理式证书 ,公钥及证书SHA-1指纹的获取方法
|
1月前
|
开发工具 iOS开发
解决Flutter运行报错Could not run build/ios/iphoneos/Runner.app
解决Flutter运行报错Could not run build/ios/iphoneos/Runner.app
94 2
|
28天前
|
Android开发 iOS开发 C#
Xamarin:用C#打造跨平台移动应用的终极利器——从零开始构建你的第一个iOS与Android通用App,体验前所未有的高效与便捷开发之旅
【8月更文挑战第31天】Xamarin 是一个强大的框架,允许开发者使用单一的 C# 代码库构建高性能的原生移动应用,支持 iOS、Android 和 Windows 平台。作为微软的一部分,Xamarin 充分利用了 .NET 框架的强大功能,提供了丰富的 API 和工具集,简化了跨平台移动应用开发。本文通过一个简单的示例应用介绍了如何使用 Xamarin.Forms 快速创建跨平台应用,包括设置开发环境、定义用户界面和实现按钮点击事件处理逻辑。这个示例展示了 Xamarin.Forms 的基本功能,帮助开发者提高开发效率并实现一致的用户体验。
69 0
|
1月前
|
运维 网络安全 iOS开发
厉害!外国网络工程师用Ansible给思科IOS设备升级!
厉害!外国网络工程师用Ansible给思科IOS设备升级!
|
1月前
|
iOS开发
解决IOS上架App Store后显示语言为英文的问题
解决IOS上架App Store后显示语言为英文的问题
45 0
|
2月前
|
人工智能 搜索推荐 vr&ar
苹果手机iOS18最新升级:植入AI人工智能,国内百度文心一言,国外GPT4o来辅助
iOS 18亮点速览:AI强化的Siri、RCS安卓消息兼容、自定义主屏、辅助功能增强,VR进步,新隐私工具,包括锁定APP和眼动追踪。Passwords app保障安全,Apple Intelligence提升个性化体验。
157 1
|
2月前
|
前端开发
uniapp 实战 -- app 的自动升级更新(含生成 app 发布页)
uniapp 实战 -- app 的自动升级更新(含生成 app 发布页)
803 1
|
2月前
|
前端开发 JavaScript
HBuilder实现App资源在线升级更新
这篇文章介绍了使用HBuilder实现App资源在线升级的流程,包括获取线上和本地版本号对比、检查更新、下载安装包、静默或用户触发安装以及重启应用。关键代码展示了如何比较版本、下载wgt文件及安装更新。注释提到仅同名文件被覆盖,manifest.json变化需整包升级。提供了一个DEMO下载链接。
100 0