Created
December 28, 2017 00:37
-
-
Save victorchee/4a2e23e8a27980669745387676f9a43c to your computer and use it in GitHub Desktop.
Upgrade from itms service.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[[NSURLSession sharedSession] downloadTaskWithURL:[NSURL URLWithString:@"https://alpha.migufun.com:38081/alpha/manifest.plist"] completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) { | |
NSDictionary *plist = [[NSDictionary alloc] initWithContentsOfURL:location]; | |
NSString *version = plist[@"items"][0][@"metadata"][@"bundle-version"]; | |
NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]; | |
if ([version compare:currentVersion options:NSNumericSearch] == NSOrderedDescending) { | |
// 需要升级 | |
NSURL *url = [NSURL URLWithString:@"itms-services://?action=download-manifest&url=https://alpha.migufun.com:38081/alpha/manifest.plist"]; | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[[UIApplication sharedApplication] openURL:url]; | |
exit(0); | |
}); | |
} | |
}] resume]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment