Implementing Force Update Feature using Firebase Remote Config in iOS

Sheeraz Ahmed Memon
CodeChai
Published in
2 min readNov 25, 2021

Requirements

  • Physical Device will helpful but not necessary

Introduction

Mobile apps are not like web apps. People download your apps from the app stores and update them if there is a new version. They may use old version of your app anytime. Let’s say old version of your app is not functional anymore. Then, you fix that and upload your new version to store but users have not updated yet. So, they think something is wrong with your app and it sucks. This problem can be solved by a implementing Force Update Feature in your app. By this I mean, when a you upload new version and you want users to use the new version, User will have no way to use the app without updating their app to new one.

Steps

Lets get our hands dirty with code. First add the so called Firebase Remote Config cocoa pod to podFile.

pod 'Firebase/RemoteConfig'

Now install the pods, After all this done, add the following helper classes.

  • ForceUpdateChecker.swift
  • UpdateAppViewController.swift

All set, now you just have to add the force update feature any where in your app. The best plan I have found it AppDelegate class’s applicationDidBecomeActive function. so lets do it.

First declare the remote config variable

var remoteConfig: RemoteConfig!

now add the following extensions for AppDelegate

Call these functions in applicationDidBecomeActive Function.

Next, goto firebase console and add the following parameters

  • force_update_store_url
  • force_update_current_version
  • force_update_required

Notes

  • Do not forget to set developerModeEnabled = false in remote config settings when releasing the app
remoteConfig.configSettings = RemoteConfigSettings(developerModeEnabled: false)!

Resources

Originally published at https://sheerazmemon.com.

--

--

Sheeraz Ahmed Memon
CodeChai

Full Stack Mobile and Web Developer with Strong skill-set on Android. Having 8+ years of development experience on Android, iOS, Flutter, and Flask.