将LeT更新到AppStore中的新版本!
LTUpdate需要iOS 4.3或更高版本。
它与ARC和MRC都兼容。但是MRC模式的测试尚未充分进行。
在为iOS 4.3构建时需要JSONKit。
pod 'LTUpdate', '~>0.0.2'
#import "LTUpdate.h"
添加到AppDelegate.m或{{YourProjectName}}-Prefix.pch。[[LTUpdate shared] update];
LTUpdate将检查来自iTunes API的新版本。如果可用新版本,将提示用户更新。用户在使用应用时可能会被UIAlertView打扰。有些人安装了您的应用,但直到新版本推广之前都没有打开过。通知是一个更好的选择。这里有一个简单的办法
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[[LTUpdate shared] updateAndPush:LTUpdateDaily];
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
[[LTUpdate shared] reduceNotification:notification then:LTUpdateNotifyThenAlert];
}
当您的应用处于不活跃状态时,它会发送一个通知提醒用户更新。
如果用户点击/滑动这个通知,将触发操作。在这种情况下,应用会显示一个提示来确认更新。或者,您可以很方便地使用[[LTUpdate shared] reduceNotification:notification];
直接打开AppStore
如果您需要更多的控制
[[LTUpdate shared] update:LTUpdateDaily
complete:^(BOOL isNewVersionAvailable, LTUpdateVersionDetails *versionDetails) {
if (isNewVersionAvailable) {
NSLog(@"New version %@ published on %@.", versionDetails.version, versionDetails.releaseDate);
NSLog(@"The app is about %@", humanReadableFileSize(versionDetails.fileSizeBytes));
NSLog(@"Release notes:\n%@", versionDetails.releaseNotes);
// Your alert view here
[[LTUpdate shared] alertLatestVersion:LTUpdateOption | LTUpdateSkip];
} else {
NSLog(@"You App is up to date.");
}
}];
输出
> New version 1.7.1 published on 2010-04-01 08:36:57 +0000.
> The app is about 245.31MB
> Release notes:
In this release Pages for iOS is updated for improved compatibility with Microsoft Word and Pages for Mac.
...
Pages 1.7.1 resolves issues related to Accessibility settings.
一个自定义示例展示了如何使用其他开源替代方案(例如MBAlertView)来替换提示视图
NSString *text = [NSString stringWithFormat:@"%@\n\n%@", LTI18N(@"A new version is available!"), versionDetails.releaseNotes];
MBAlertView *alertView = [MBAlertView alertWithBody:text
cancelTitle:LTI18N(@"Remind Me Later") cancelBlock:nil];
[alertView addButtonWithText:LTI18N(@"Update") type:MBAlertViewItemTypeDefault block:^{
[[LTUpdate shared] openAppStore];
}];
alertView.bodyFont = [UIFont systemFontOfSize:11];
[alertView addToDisplayQueue];
[[LTUpdate shared] clearSkippedVersion];
NSString *humanReadableFileSize(unsigned long long int size);
将文件大小格式化为"123.45MB"样式static NSString *kAppName();
是当前应用的显示名称static NSString *kAppVersion();
是当前应用的版本static NSString *LTI18N(NSString *key);
返回LTUpdate.strings中的本地化字符串。更多详情请参考LTUpdate.h.
AppStore审阅者不会看到提示。因为提交的版本总是大于AppStore中的在线版本。
不包括UI功能的测试覆盖率约为70%。
在构建前安装JSONKit。
git submodule init
git submodule update
此代码根据MIT许可证的条款和条件分发。有关详细信息,请参阅LTUpdate.h。