如何通过无线方式更新ios6企业应用程序

你好,我们最近开发了第一个企业应用程序。 我们正在使用“内部”选项来创build分发证书。 客户端尚未使用该应用程序。 但他很快就会使用它。 同时我有一个问题。 他会使用这个应用程序,如果将来有更新的应用程序,我们希望客户端也更新。 就像现在我有我的iPhone上安装的应用程序。 我从AppStore获得更新说XYZ应用程序已被更新。 所以我安装更新。 现在,如果我们的客户端正在使用应用程序并保存了一些数据(我们的应用程序使用核心数据,而且我们以一种客户端可以在设备上存储一些数据的方式构build它),我们想要发送一个更新给他,更新,但不能删除任何现有的客户端数据。这是可能的吗? 我该怎么做?我现在正在使用无线安装来安装应用程序。 我们有一个安全的服务器,里面有.ipa和.plist文件,我们有一个下载html页面。 客户端点击链接并安装应用程序。 请让我知道,如果你需要更多的信息。 谢谢。

对的,这是可能的。 在部署企业应用程序时,需要一个包含有关应用程序元数据的plist。 此元数据包含可用于检查更新的版本号。

BOOL updateAvailable = NO; NSDictionary *updateDictionary = [NSDictionary dictionaryWithContentsOfURL: [NSURL URLWithString:@"http://www.example.com/pathToPlist"]]; if(updateDictionary) { NSArray *items = [updateDictionary objectForKey:@"items"]; NSDictionary *itemDict = [items lastObject]; NSDictionary *metaData = [itemDict objectForKey:@"metadata"]; NSString *newversion = [metaData valueForKey:@"bundle-version"]; NSString *currentversion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; updateAvailable = [newversion compare:currentversion options:NSNumericSearch] == NSOrderedDescending; } 

一旦检测到更新可用,请将用户导航到下载URL

itms-services://?action=download-manifest&url=<url-path-to-plist>

它将在现有版本上安装,从而保留所有数据,甚至可以升级CoreData数据库,如果您设置自动迁移并进行更改。

感谢Joe提供了一个非常棒的回应。 这里是扩展版本翻译成swift。 你可以把它放在你的主视图控制器的viewDidLoad

 let plistUrl = "https://example.com/example.plist" let installationUrl = "itms-services://?action=download-manifest&amp;url=https://example.com/example.plist" override func viewDidLoad() { super.viewDidLoad() //Check for the updates checkForUpdates() } func checkForUpdates() { let qualityOfServiceClass = QOS_CLASS_BACKGROUND let backgroundQueue = dispatch_get_global_queue(qualityOfServiceClass, 0) dispatch_async(backgroundQueue, { let updateDictionary = NSDictionary(contentsOfURL: NSURL(string: self.plistUrl)!)! let items = updateDictionary["items"] let itemDict = items?.lastObject as! NSDictionary let metaData = itemDict["metadata"] as! NSDictionary let serverVersion = metaData["bundle-version"] as! String let localVersion = NSBundle.mainBundle().infoDictionary!["CFBundleVersion"] as! String let updateAvailable = serverVersion.compare(localVersion, options: .NumericSearch) == .OrderedDescending; if updateAvailable { self.showUpdateDialog(serverVersion) } }) } func showUpdateDialog(serverVersion: String) { dispatch_async(dispatch_get_main_queue(), { () -> Void in let alertController = UIAlertController(title: "New version of Example available!", message: "Example \(serverVersion) has been released. Would you like to download it now?", preferredStyle: UIAlertControllerStyle.Alert) alertController.addAction(UIAlertAction(title: "Not now", style: .Cancel,handler: nil)) alertController.addAction(UIAlertAction(title: "Update", style: .Default, handler: { (UIAlertAction) in UIApplication.sharedApplication().openURL(NSURL(string: self.installationUrl)!) })) self.presentViewController(alertController, animated: true, completion: nil) }) } 

只要分发更新就像分发原始文件一样。 用户保留早期版本的数据。

对于应用程序更新,如果应用程序的包ID保持不变,则现有的应用程序数据将保持不变。

苹果在此解释企业应用程序部署和应用程序更新: http : //help.apple.com/iosdeployment-apps/mac/1.1/#app43ad802c

我还build议在应用程序中包含更新检查器。

要做到这一点,iVersion是Nick Lockwood(又名木炭devise)的ios库,它可以帮助你做到这一点。 它在这里可用: https : //github.com/nicklockwood/iVersion