git地址:https://github.com/yangchao0033/Harpygit
###(iOS5-9适配版本,基于ArtSabintsev/Harpy v3.4.5)github
Harpy 将用户手机上已安装的iOS app版本与当前App Store最新可用版本进行检查对比。若是有新的可用版本时,使用弹窗及时提醒用户最新版本信息,并然用户选择是否须要进一步操做。swift
Harry是基于[http://www.semver.org](Semantic Versioning)版本号系统标准执行。app
Semantic Versioning
是一个三位数的版本号系统(例如:1.0.0)当前兼容版本(iOS5-9)暂时不支持swiftthis
HarpyAletType
枚举进行控制,详见Harpy.h
将‘Harpy’文件夹拖入到你的项目中,并选择'copy if needed',包括 Harpy.h
和 Harpy.m
文件spa
Appdelegate
中设置appID(必要),设置你的alertType(可选)Appdelegate
中调用checkVersion
方法,三个检测方法调用位置分别位于Appdelegate的启动的代理方法中,能够自行选择使用
application:didFinishLaunchingWithOptions:
中调用 checkVersion
applicationDidBecomeActive:
中调用 checkVersionDaily
applicationDidBecomeActive:
中调用 checkVersionWeekly
.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 启用Harpy以前确保你的window可用 [self.window makeKeyAndVisible]; // 为你的应用设置app id [[Harpy sharedInstance] setAppID:@"<#app_id#>"]; // 设置 UIAlertController 将要基于哪一个控制器显示 (适配iOS8+) [[Harpy sharedInstance] setPresentingViewController:_window.rootViewController]; // (可选)设置代理来追踪用户点击事件,活着的使用自定义的界面来展现你的信息 [[Harpy sharedInstance] setDelegate:self]; // (可选) 设置alertController的tincolor(iOS8+可用) [[Harpy sharedInstance] setAlertControllerTintColor:@"<#alert_controller_tint_color#>"]; // (可选) 设置你的应用名 [[Harpy sharedInstance] setAppName:@"<#app_name#>"]; /* (可选)设置弹框类型 默认为HarpyAlertTypeOption */ [[Harpy sharedInstance] setAlertType:<#alert_type#>]; /* (可选)若是你的应用只在某些国家或地区可用,你必须使用两个字符的country code来设置应用的可用区域 */ [[Harpy sharedInstance] setCountryCode:@"<#country_code#>"]; /* (可选) 强制指定应用显示语言, 请使用 Harpy.h 中定义的 HarpyLanguage 进行设置。*/ [[Harpy sharedInstance] setForceLanguageLocalization:<#HarpyLanguageConstant#>]; // 执行版本检测 [[Harpy sharedInstance] checkVersion]; } - (void)applicationDidBecomeActive:(UIApplication *)application { /* 执行天天检测你的app是否须要更新版本,须要在`applicationDidBecomeActive:`执行最合适 由于这对于的你的应用进如后台很长时间后很是有用。 同时,也会在应用第一次启动时执行版本检测 */ [[Harpy sharedInstance] checkVersionDaily]; /* 执行每周检测你的app新版本。同理须要将此代码放置在`applicationDidBecomeActive:`中执行。 同时,也会在应用第一次启动时执行版本检测 */ [[Harpy sharedInstance] checkVersionWeekly]; } - (void)applicationWillEnterForeground:(UIApplication *)application { /* 执行app新版本检测,放在此是为了让用户从App Sore跳转回来并从新从后台进入你的 app,而且没有在从App Store中跳转回来以前更新他们app的时候调用 注意:只有当你使用*HarpyAlertTypeForce*样式弹框类型是才使用这种方法 而且会在你第一次启动应用时检测。 */ [[Harpy sharedInstance] checkVersion]; }
项目上线遇到的问题:代理
下午提交的审核,当晚2点就过审了,而后次日发现并无更新弹框提示....
解决:code
/** Checks to see when the latest version of the app was released. If the release date is greater-than-or-equal-to `_showAlertAfterCurrentVersionHasBeenReleasedForDays`, the user will prompted to update their app (if the version is newer - checked later on in this method).
查看应用程序的最新版本什么时候发布。若是发布日期大于或等于“_showalertaftercurrentversionhasbeenreleaseddays(默认是1天)”,
用户将提示更新他们的应用程序(若是版本更新—稍后在此方法中检查)。
*/ NSString *releaseDateString = [[results valueForKey:@"currentVersionReleaseDate"] objectAtIndex:0]; if (releaseDateString == nil) { return; } else { NSInteger daysSinceRelease = [weakSelf daysSinceDateString:releaseDateString]; if (!(daysSinceRelease >= weakSelf.showAlertAfterCurrentVersionHasBeenReleasedForDays)) { NSString *message = [NSString stringWithFormat:@"Your app has been released for %ld days, but Siren cannot prompt the user until %lu days have passed.", (long)daysSinceRelease, (unsigned long)weakSelf.showAlertAfterCurrentVersionHasBeenReleasedForDays]; [self printDebugMessage:message]; return; } }
daysSinceRelease如今是为0,因此才会没有弹框提示,等一天就能够看到更新弹框了