iOS 检测版本升级比较好用的第三方类库Harpy的简单使用

来源:互联网 发布:eia数据今天数据 编辑:程序博客网 时间:2024/06/05 05:22

http://blog.sina.com.cn/s/blog_b4df5c330102vd06.html

- (void)checkUpdate

{


    

    if (flag) {

        

        [[HarpysharedInstance] setAppID:@"1111111"];

        

        [[HarpysharedInstance] setPresentingViewController:self.window.rootViewController];

        

        [[HarpysharedInstance] setAlertType:HarpyAlertTypeSkip];

        

        [[HarpysharedInstance] setAppName:NSLocalString(@"CFBundleDisplayName")];

        

        [[HarpysharedInstance] checkVersion];

        

    }

   // NSLog(@"ddd");

}



1.  如果还没有此类库,https://github.com/ArtSabintsev/Harpy/blob/master/samplePictures/picOptionalUpdate.png?raw=true

2.或者用CocoaPods 
### Installation Instructions


#### CocoaPods Installation

```

pod 'Harpy'

3.下载后只把Harpy 文件夹导入工程,
剩下的就是在工程的AppDelegate.h/Pre-Compiler Header (.pch) 文件倒入Harpy.h 头文件
4. 在AppDelegate.m的一下方法中加入这些更新代码,这个是一个单例类
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{


  [[Harpy sharedInstance]setAppID:APP_ID];//appid 是你申请发布时对应的id  

                [[Harpy sharedInstancesetAppName:appName]; //这个是你的工程名字

                [[Harpy sharedInstance] setPresentingViewController:_window.rootViewController];设置弹出提示框的控制器

                [[Harpy sharedInstance]setCountryCode:APP_COUNTRY_CODE];设置国际默认吗

                [[Harpy sharedInstance]setAlertType:HarpyAlertTypeOption];选择提示框

                [[Harpy sharedInstance]             setForceLanguageLocalization:HarpyLanguageChineseSimplified];设置语言

                [[Harpy sharedInstance]checkVersion];检测更新

}

5.

- (void)applicationDidBecomeActive:(UIApplication *)application

{

 

 

[[Harpy sharedInstance] checkVersionDaily];每天更新


 

[[Harpy sharedInstance] checkVersionWeekly];每周更新

    

 

}

6.

- (void)applicationWillEnterForeground:(UIApplication *)application

{

 

[[Harpy sharedInstance] checkVersion];    

 

}

7.宏定义选取版本

//app版本升级获取对比

#define APP_VERSION_NUM [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

//获取版本名字

 

#define APP_NAME_DISPLY [[[NSBundle mainBundle]infoDictionary] objectForKey:(NSString *)kCFBundleNameKey]


8.//APP 版本升级发布的ID

#define APP_ID @"909253"

#define APP_COUNTRY_CODE @"086"

9.把如下东西添加上去就可以了,注意版本号形式是:1.0.0。


0 0