TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Lex Tang.
LeT's Update to the new version available in the AppStore!
LTUpdate requires iOS 4.3 or newer.
It's compatible with both ARC and MRC. But MRC mode is not well tested yet.
JSONKit is required while you are building for iOS 4.3.
pod 'LTUpdate', '~>0.0.2'
#import "LTUpdate.h"
to AppDelegate.m or {{YourProjectName}}-Prefix.pch.[[LTUpdate shared] update];
LTUpdate will check new verison from iTunes API. And prompt the user to update if there is a new version available.Users may be disturbed by UIAlertView while they supposed to use the app. Some of them installed your app but never open it till the new version has been promoted. Notifications is a better choice. Here is the simple way:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[[LTUpdate shared] updateAndPush:LTUpdateDaily];
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
[[LTUpdate shared] reduceNotification:notification then:LTUpdateNotifyThenAlert];
}
While your app become inactived, it would send a notification to notify the user to update.
If the user tap/swiped this notification, the action would be invoked. In this case, the app will show a alert to make confirm of update. Or it’s quite nifty to open AppStore directly with
[[LTUpdate shared] reduceNotification:notification];
If you need more control:
[[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.");
}
}];
Outputs:
> 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.
A customized example shows you how to replace the alert view with other open source alternatives(MBAlertView for example):
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);
formats file size to "123.45MB" style;static NSString *kAppName();
is the display name of current App;static NSString *kAppVersion();
the version of current App.static NSString *LTI18N(NSString *key);
return localized string in LTUpdate.strings.Learn more in LTUpdate.h.
The AppStore reviewer will not see the alert. Because the submitted version is always greater than the online version in AppStore.
Testing coverage is about 70% exclude UI functions.
Install JSONKit before build.
git submodule init
git submodule update
This code is distributed under the terms and conditions of the MIT license. See LTUpdate.h for details.