Update Mobile App Dynamically



I have worked in mobile space for majority of my career and one thing that I always
wanted to achieve was to fix bugs and send crucial updates on a fly.

We can do that in websites which makes development of new features fast and bugs don’t
hurt the business that much = Happy Customers, we all know that is not the case with
mobile apps.

Enters React Native which not only lets you build beautiful apps with native look and feel
for both Android and IOS but because its JavaScript we can even bundle our new releases
and configure our app to query and download these bundles from our servers to update/add
new features without prompting our users to download an update.

How does it work?

If you have worked on React Native you know that we can reflect code changes on devices
just by enabling hot reload from the developer menu. So there is a mechanism that loads a
bundle, updates the files and re renders the screen with the changes.
We just need to provide the bundle.

How can we do it?

All we need to do is to:
  • Maintain versioning of our JavaScript and assets files.
  • Develop a release management system which will create a bundle of all the files which are updated by checking their versions and make a downloadable release bundle.
  • Our apps need to query our servers, download the bundle asynchronously and provide react native with that bundle.
All of which is easier said than done!

How to do it quickly?

I came across two portals which provide these services for free: -

  • Apphub (https://apphub.io/):
    Currently Apphub only supports IOS platform So I will not go into details about this. You can check it out from the link provided.
  • AppCenter (https://appcenter.ms):
    It is a dashboard provided by Microsoft offering a ton of features like automated builds, analytics, crash reporting, build distribution to name a few.
    But we are more interested in Code Push service which has an easy installation(https://docs.microsoft.com/en-us/appcenter/distribution/codepush/) for both Android and IOS. Just go to the link and follow the installation steps and you will be good to go.


    Code push lets you:-
    • Mark files which you want to update dynamically.
    • Configures your app with a single command to request for updated bundles from server in a number of ways like on restart,app resume etc.
    • Once you have made your changes just push your code in repo and release the app using Appcenter release command “code-push release-react <App name> Android -d Staging” and your app will be updated.
Few pointers once you visit App center
    • Create two apps for android and IOS this will help you maintain different releases for both the platforms.  Also you will need app secrets during your configuration.
    • You will have two keys for staging and release which you can use to test your release on staging devices and then promote to release env. Where it will be distributed to devices having release key.
    • You will have to release your bundles for ios and android separately.
    • Even though Appcenter configures your app using a simple command still I will recommend you to cross verify changes with their manual guide to get a better understanding of what code push is doing.

May the force be with you!! :)

Comments