0
我正在开发IOS应用程序。我有一个使用案例,我们必须强制用户进行升级。例如,用户可能位于版本1和另外两个版本2和3(目前存在于应用商店中)。现在我们确定版本1存在安全漏洞,因此我们打开一个警报,要求用户通过应用商店升级。我的做法,现在是如下: -根据最低版本标准为IOS应用程序实施强制更新
1. Implement a rest service which vends the minimum required version.
2. Implement a local upgrade handler that calls the rest service,
gets the current version(natively) and compares the version
against the min required version.
3. If the version is lower than min required version, upgrade by
opening app store.
到目前为止,我已经能够成功地实现了REST服务和升级处理程序的一部分。我的警报视图代码看起来如下所示: -
private func alertUserWithHandler(title: String?, message: String, upgradeHandler: ((UIAlertAction) -> Void)?){
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: upgradeHandler))
self.presentViewController(alert, animated: true, completion: nil)
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
}
而且我升级处理器看起来为如下: -
// The upgrade handler takes the user to the AppStore.
func upgradeHandler(action:UIAlertAction) {
UIApplication.sharedApplication().openURL(NSURL(string:"location in appstore"))
}
这种方法的问题是它不是一个阻塞处理程序。用户可以按确定按钮,然后去应用程序商店,然后回来继续使用该应用程序。我们要强制升级(即用户在升级成功完成之前不能使用该应用程序)。
任何人都可以提出一个强制用户升级的好方法吗?
你可以在没有按钮的'upgradeHandler()'中显示另一个AlertController。 – FelixSFD
@FelixSFD - 好的,但我怎么会传递一个处理程序? –
您可以在应用启动时发送带有用户验证请求的应用版本。所以在后端,如果版本太旧,它会返回一个错误。在应用程序中,你需要单独处理这个错误。 – MaksTheAwesome