In iOS apps, it’s important that developers create a way to check the user’s app version and force the user to update the app. This solution not only requires code handling at the app level but also in the app backend. This solution will help in migrating all users to new functionality smoothly.
The default App Store setting to automatically download app updates can be really helpful in the majority of the cases. But in some situations, when the update is urgent and not optional, developers need to have an in-built mechanism to force users to update their apps. In apps, it’s not easy to move users to earlier/older versions. So, in cases, if some issues occur in the app’s latest version which requires urgent and mandatory updates, these mechanisms can be really helpful.
Exceptional scenarios aside, this mechanism can also help in improving users’ overall experience. Users’ can be easily updated to new versions with the latest features and bug fixes.
Apple default mechanisms have a great pull factor to encourage users to update to the latest version of iOS. iOS through badging/notifications informs the user about the latest OS versions. Developers rarely need to worry about giving support to very old iOS versions. This really helps if the app supports only a few latest released versions of iOS. Also, users will only be able to see the latest update their device is eligible for. This reduces risk if the latest app versions only support the latest iOS releases and the team wishes to drop their support for older OS versions. But in this case, too, letting the user know about the latest app updates can be really helpful.
It’s important that this force update feature is included even in the very first version of the app. Otherwise, forcing all users to upgrade won’t be possible in later stages.
The first step includes getting the latest app version from your backend API. In the next step, developers need to fetch the current app version. Then these two versions should be compared. If the version is found to be older then, redirect the user to the app store.
To get the app version, use the below-mentioned code :
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
To send the user to an app store, use the following code :
if let url = URL(string: "itms-apps://apple.com/app/App_Store_Id) { UIApplication.shared.open(url) }
Another Way to achieve force update is through Updates open-source framework. This provides functionality to automatically check newer versions of the app. It presents the newer version number and other information regarding the latest update.
Updates use iTunes Search API to get the latest version of your app available from the app store. It also fetches the additional information provided by the development team for the latest release. This informs the user about the latest features too.
This framework also automatically ensures that the app update is for the relevant App Store location/country.
If a user elects to update then, the framework can present the App store using SKStoreProductViewController. This makes the developers’ tasks simple and the user experience smooth.
To configure this framework use the following code. The configuration is done using a JSON configuration file from a URL, or a local file in the app.
let URL = "https://domainname.com/file.json" Updates.configurationURL = URL(string: URL) (or) Updates.configurationURL = Bundle.main.url(forResource: “Filename,” withExtension: "json")
A configuration file may look something similar to the below text :
{ "updates": { "check-for": "automatically", "notify": "once" } }
The framework looks for a top-level key “updates”, for “notify” key, other than “once”, “twice”, “thrice”, “always” etc. values can also be used.
The configuration can also be done programmatically, this let go of the need for a JSON file.
Updates.updatingMode = .automatically Updates.notifying = .always
Conclusion :
It is advised for developers to plan for any need to migrate users to the latest version of an app. The Update framework provides for the automatic query of the latest version of the app and can also display the alert to the user.