ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## ZLAppUpdate检测升级 ## * 1.请求APPStore上当前版本信息 * 2.自定义更新模式:强制更新,非强制更新 * 3.显示最新版本的新功能描述 * 4.支持iOS macOS @interface ZLAppUpdate : NSObject /** 版本更新优先级 */ ``` typedef NS_ENUM(NSInteger, iVersionUpdatePriority) { iVersionUpdatePriorityDefault = 0, iVersionUpdatePriorityLow = 1, //忽略 iVersionUpdatePriorityMedium = 2, //回头再说 iVersionUpdatePriorityHigh = 3 //强制更新 }; ``` ``` + (ZLAppUpdate *)sharedInstance; ``` #### 自定义属性 ``` /** app store ID */ @property (nonatomic, assign) NSUInteger appStoreID; /** 应用的版本号 */ @property (nonatomic, copy) NSString *applicationVersion; /** 应用的BundelID */ @property (nonatomic, copy) NSString *applicationBundleID; /** 应用所在区域 */ @property (nonatomic, copy) NSString *appStoreCountry; /** 使用设置 */ @property (nonatomic, assign) BOOL showOnFirstLaunch; /** 标题和详细信息格式 */ @property (nonatomic, assign) BOOL groupNotesByVersion; /** 检测更新时间间隔 */ @property (nonatomic, assign) float checkPeriod; /** 忽略时间间隔 */ @property (nonatomic, assign) float remindPeriod; //标题信息 @property (nonatomic, copy) NSString *inThisVersionTitle; /** 有新的版本 */ @property (nonatomic, copy) NSString *updateAvailableTitle; /** 版本号 */ @property (nonatomic, copy) NSString *versionLabelFormat; /** 好的 */ @property (nonatomic, copy) NSString *okButtonLabel; /** 忽略 */ @property (nonatomic, copy) NSString *ignoreButtonLabel; /** 回头再说 */ @property (nonatomic, copy) NSString *remindButtonLabel; /** 下载 */ @property (nonatomic, copy) NSString *downloadButtonLabel; //调试信息 /** 需要提示的 权重 */ @property (nonatomic, assign) iVersionUpdatePriority updatePriority; /** alertController是否可用 */ @property (nonatomic, assign) BOOL useUIAlertControllerIfAvailable; /** 语言是否可用 */ @property (nonatomic, assign) BOOL useAllAvailableLanguages; /** 仅在MainWindow中展示 */ @property (nonatomic, assign) BOOL onlyPromptIfMainWindowIsAvailable; /** 如果没有本地list展示APPStore更新信息 */ @property (nonatomic, assign) BOOL useAppStoreDetailsIfNoPlistEntryFound; /** 是否检测更新 */ @property (nonatomic, assign) BOOL checkAtLaunch; /** 是否需要打印日志 */ @property (nonatomic, assign) BOOL verboseLogging; @property (nonatomic, assign) BOOL previewMode; /** app的plistURL */ @property (nonatomic, copy) NSString *remoteVersionsPlistURL; /** 本地Plist文件路径 */ @property (nonatomic, copy) NSString *localVersionsPlistPath; /** 忽略的版本号 */ @property (nonatomic, copy) NSString *ignoredVersion; /** 最后检测的时间 */ @property (nonatomic, strong) NSDate *lastChecked; /** 最后忽略的时间 */ @property (nonatomic, strong) NSDate *lastReminded; /** 更新的APP的URL */ @property (nonatomic, strong) NSURL *updateURL; /** 是否展示版本的详细信息 */ @property (nonatomic, assign) BOOL viewedVersionDetails; /** 代理 */ @property (nonatomic, weak_delegate) id<ZLAppUpdateDelegate> delegate; ``` ### 实现方法 ``` /** 是否打开APPStore中APP页面 */ - (BOOL)openAppPageInAppStore; /** 检测新版本 */ - (void)checkIfNewVersion; /** 新版本的详细信息 */ - (NSString *)versionDetails; /** 是否需要检测更新 */ - (BOOL)shouldCheckForNewVersion; /** 更新新版本 */ - (void)checkForNewVersion; ``` 提示语言切换 ``` 中文 "iVersionInThisVersionTitle" = "更新说明"; "iVersionUpdateAvailableTitle" = "有新的版本"; "iVersionVersionLabelFormat" = "版本 %@"; "iVersionIgnoreButton" = "忽略"; "iVersionDownloadButton" = "下载更新"; "iVersionRemindButton" = "回头再说"; "iVersionOKButton" = "好的"; ``` ``` 英文 "iVersionInThisVersionTitle" = "New in this version"; "iVersionUpdateAvailableTitle" = "New version available"; "iVersionVersionLabelFormat" = "Version %@"; "iVersionIgnoreButton" = "Ignore"; "iVersionDownloadButton" = "Download"; "iVersionRemindButton" = "Remind Me Later"; "iVersionOKButton" = "OK"; ``` ### iOS使用方法示例 ``` [ZLAppUpdate sharedInstance].applicationBundleID = [[NSBundle mainBundle]bundleIdentifier]; [ZLAppUpdate sharedInstance].updatePriority = iVersionUpdatePriorityDefault; ```