introduce

I’ve been working on a complex React Native connection project these days, and I’m nearing the end. I’ve written FlyOceanMovies before, but it’s relatively simple. So this time I picked a very complicated project and wrote another one. However, the purpose of this article is not to summarize the project, and a separate article will be written later to summarize it. This post is about the React Native hot update.

React Native’s biggest advantage is that it works with both Android and iOS platforms, but it also has an obvious advantage of hot updates. So how do you implement hot updates to RN?

There are also mature hot update services in the market, such as MicroSoft CodePush and React Native Chinese Pushy. However, in many cases, companies may have to build their own hot update server, after all, it is not very good to put the code and controller on other servers. The author summarizes the following relatively mature schemes.

Hot update scheme

Full calorimetric renewal

This hot update is relatively simple to implement and saves time and effort.

Incremental thermal update

More complex to achieve, save traffic, user experience will be better

Set up your own CodePush server

In fact, the codePush system is built on your own server, which is easier and less troublesome. Except that the server address is different from Microsoft’s, everything else is exactly the same.

Incremental hot update (patch generation through algorithmic comparison)

1. The server uses the BSDIff algorithm to generate a patch file between the old RN package and the new RN package for the client to download.

2. The client downloads the patch file and generates a new RN package by combining the patch file with the old RN package.

  • google-diff-match-patch

This algorithm is supported by very many languages by text comparison

  • Bsdiff, bspatch

C language is written a tool, comparison is binary files

Comparison diagram of the two:

Refer to the article