您的位置:首页 > 移动开发

OS如何取得APP的版本信息跟服务器对比进行升级提示?

2014-07-30 15:34 567 查看
关键是自动取版本信息:

[NSString stringWithFormat:@"Version %@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];

[NSString stringWithFormat:@"Build %@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];

#define APP_DownloadURL @"http://itunes.apple.com/app/id483504146?mt=8" //换成你自己的APP地址

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

    if (buttonIndex != [alertView cancelButtonIndex])

    {

       NSURL *url = [NSURL URLWithString:APP_DownloadURL];

       [[UIApplication sharedApplication] openURL:url];

    }

}

-(void)alertUpdate:(NSString *)strContent

{

    if (!isAlertUpdateShowed) {

        isAlertUpdateShowed=YES;

        UIAlertView *av = [[[UIAlertView alloc] initWithTitle:@"升级提示"

                                                      message:strContent

                                                     delegate:self       //委托给Self,才会执行上面的调用

                                            cancelButtonTitle:@"以后再说"

                                            otherButtonTitles:@"马上更新",nil]
autorelease];

        [av show];

    }

}

-(void)checkUpdate

{

    NSString* sLastVersion=@"1.1"; //取最新的版本自己去实现

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios
相关文章推荐