这个库是一种简单易用的方式来检查您的iOS App Store上的应用是否有更新可用的。
这是这个库的第一个版本,包含调用Apple的查找服务并返回您应用的当前数据的所有基本功能。这意味着您的应用必须在App Store中批准且处于活动状态才能正常工作。在每一步都内置了应急措施,如果发生任何变化或没有正确返回,则返回NO以表示没有可用的更新。这样,您应该可以放心地将检查设置为不需要意外提示用户更新。
该库假设您正在使用语义版本控制为您的应用设置版本。这意味着您的版本设置为以下格式。
MAJOR.MINOR.PATCH
为了让这个库工作,您的版本必须是 NSString
(由于Apple要求必须是这种方式,所以很容易设置)并且您的项用句点分隔。假设您正在使用这种版本控制方式,该库将为您正常工作。
您可以在检查更新中指定您希望查找有多精确。也许您只关心在发布主要或次要更新时提示用户,但不想为错误修复而烦扰他们。
SMAVersionTypeMajor // only prompts for update if major version changes
SMAVersionTypeMajorMinor // only prompts for update if major or minor version changes
SMAVersionTypeMajorMinorBug // only prompts for update if major, minor, or bug version changes
SMAVersionTypeDefault // will prompt for update at any level of update
[SMAUpdatesAvailable checkForUpdatesWithType:SMAVersionTypeMajorMinorBug onCompletion:^(SMAUpdateResponse *response) {
if (response.updateAvailable) {
// safe to prompt user to update your app
} else {
// no updates available
}
}];
SMAUpdateResponse
对象包含用于检查更新的所有数据。如果您愿意,可以查询响应并自行解析数据。
response.appVersion // current version of your app as reported by MainBundle
response.appStoreVersion // current version of your app as reported by Apple's lookup service (if returned)
response.updateAvailable // BOOL to quickly determine if update is available for your app
response.rawData // NSDictionary of the full response returned by Apple's lookup service (has a lot of Store information)
response.error // error returned in the event of failures at any point and can be helpful for user messages if needed
#import "SMAUpdatesAvailable.h"
放在想要检查更新的位置pod install SMAUpdatesAvailable
SMAUpdatesAvailable
和 SMAUpdateResponse
即可SMAUpdatesAvailable 需要[iOS 8.0]或更高版本。我们将努力使它在经过适当的测试后能够提供到尽可能多的版本。
SMAUpdatesAvailable 是为使用 Simply Made Apps 创建的项目编写的,这样我们可以帮助用户更新到我们应用程序的最新版本。
SMAUpdatesAvailable 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。