IOSAPP提示更新软件的功能的方法

1,登录成功,后台发给最新的版本号,名称,最新内容,然后与当前应用的版本作比较,如有新版本,弹出提示,同时链接到新颁布的appstore url下载更新替换之。

2,非常简单的实现方式:

获取本机的版本

NSDictionary *infoDictionary = [[NSBundlemainBundle] infoDictionary];

 NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];

,然后解析Apple网站的  版本号,直接对比,不一样就让他升级。

从http://itunes.apple.com/lookup?id=<Your app ID>得到JSON数据,里面包含版本信息,比较一下就可以了。 

(关于这个app ID:去apple上填写发布程序时,会生成app id)

得到的json数据:苹果会返回应用对应的所有信息,直接在登录请求时,保存这些版本信息,如有更新时,直接使用提示就行了,(点击链接到appStore)不过记得每次更新时把本地的版本号(变量)更新了。

3,利用apple的push服务,实现颁布更新的功能。这个需要利用push 服务,目前我应用还不太需要push 消息,所以没有接触过,等以后再补充把。




步骤:1.新建一个项目;安装platform :ios, '7.0'
                                           pod "AFNetworking", "2.0.0"
                                           pod 'KissXML', '~> 5.0'

                                           相关类库

          2.



//

//  ViewController.m

//  KissXML

//

//  Created by zbh on 14-8-22.

//  Copyright (c) 2014 zbh. All rights reserved.

//


#import "ViewController.h"

#import "AFHTTPRequestOperationManager.h"

@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

    

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    [manager GET:@"http://itunes.apple.com/lookup?id=861183156" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

//        NSLog(@"JSON: %@", responseObject);

        

            NSArray *app=[responseObject objectForKey:@"results"];

            NSDictionary *dic=[app lastObject];

            NSString *version1=[dic objectForKey:@"version"];

            NSLog(@"%@",version1);

        

        NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];

        NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];

        NSLog(@"%@",version);

      

        

        if (version1>version) {

            NSLog(@"升级");

            UIAlertView* alert=[[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"请升级软件" delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"确认", nil];

            [alert show];

        }

        

        

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

        NSLog(@"Error: %@", error);

    }];

    


    

    

}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

    

    NSString* msg = [[NSString alloc] initWithFormat:@"您按下的第%d个按钮!",buttonIndex];

         NSLog(@"%@",msg);

    if (buttonIndex==1) {

        NSLog(@"OKO");

     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/sue-rong-shang-hai-zheng-quan/id861183156?mt=8"]];

    }

}



- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值