LTUpdate 0.0.2

LTUpdate 0.0.2

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最新发布2014年12月

Lex Tang维护。



LTUpdate 0.0.2

  • Lex Tang

将LeT更新到AppStore中的新版本!

Screenshot

功能

  • 本地通知 —— 从0.0.2版本开始。
  • 自定义回调。您可以使用您喜欢的视图类来提示新版本。
  • 多语言。0.0.1版本包含25种语言。
  • 更新周期控制。每日/每周/每月
  • “跳过此版本”
  • 版本详情(发布日期、文件大小(字节)、发布说明...)
  • ARC/MRC兼容
  • 基于Block的接口
  • GCD

需求

LTUpdate需要iOS 4.3或更高版本。

它与ARC和MRC都兼容。但是MRC模式的测试尚未充分进行。

在为iOS 4.3构建时需要JSONKit

用法

拖放或pod安装

  • 下载zip文件并解压缩。将LTUpdate/LTUpdate文件夹拖放到您的项目中。
  • 但我更喜欢CocoaPods: pod 'LTUpdate', '~>0.0.2'

定义App ID

  • 将具有键“APP_STORE_ID”的NSNumber字段添加到{{YourProjectName}}-Info.plist中,并将App ID作为值:Screenshot

导入头文件

  • 之后,将#import "LTUpdate.h"添加到AppDelegate.m或{{YourProjectName}}-Prefix.pch。

使用UIAlertView进行提示

  • 在applicationDidBecomeActive:中调用更新方法 [[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];
}

当您的应用处于不活跃状态时,它会发送一个通知提醒用户更新。

Screenshot

如果用户点击/滑动这个通知,将触发操作。在这种情况下,应用会显示一个提示来确认更新。或者,您可以很方便地使用[[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];

清除UserDefaults中的SkippingVersion

[[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审阅者不会看到提示。因为提交的版本总是大于AppStore中的在线版本。

测试与构建演示

不包括UI功能的测试覆盖率约为70%。

在构建前安装JSONKit

git submodule init
git submodule update

许可

此代码根据MIT许可证的条款和条件分发。有关详细信息,请参阅LTUpdate.h。