Reputation:
I am developing an IOS Application. I have a use case in which we have to force users to necessarily upgrade. For example the user might be on version 1 and two more versions 2 and 3(which exists on app store currently). Now we determined that version 1 has a security vulnerability so we open an alert which asks for user to upgrade via app store. My approach right now is the follows:-
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.
So far I have been able to successfully implement the rest service and part of the upgrade handler. My alert view code looks as the following:-
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))
}
And my upgrade handler looks as the follows:-
// The upgrade handler takes the user to the AppStore.
func upgradeHandler(action:UIAlertAction) {
UIApplication.sharedApplication().openURL(NSURL(string:"location in appstore"))
}
The problem with this approach is its not a blocking handler. The user might press Ok button and then go to app store and then come back to resume using the app. We want to force an upgrade (i.e the user cannot use the app until the upgrade is sucessfully completed).
Can anyone suggest a good way to force user upgrades?
Upvotes: 0
Views: 2915
Reputation: 3932
I created a sharedInstance() in a Singleton class that hits a web service with version and build as parameters. If it comes back true, I present a view modally over the app that cannot be dismissed until that web service comes back false. By putting it into a sharedInstance I don't have to call it on every view controller. I also call it once when the app launches initially as well.
Upvotes: 1