Recently, the company wanted to develop a mobile terminal project using the Ionic framework. The project director asked for thermal update, so he looked at the thermal update function of ionic and found two approaches.

  1. Hot Code Push plug-in

Microsoft maintenance of a set of hot update plug-in, support android and ios, easy to use. It needed to push packaged front-end resources to its server, but the project director did not agree, so it gave up.

In addition, I didn’t find any other plug-ins. I have to make fun of ionic’s ecology. There are too few plug-ins and the quality is poor.

Some attempts:

So I thought, if the front-end resources are deployed online, is it feasible to let the APP load online resources?

First thought of loading online web pages via iframe:

<body>
  <! -- <app-root></app-root> -->
  <iframe src="http://192.168.1.148:8000" style="width: 100%; height: 100%;" frameborder="0"></iframe>
</body>
Copy the code

Note that the body tag will not display due to the ionic style, so rewrite the style:

body {
    display: unset ! important;
}
Copy the code

At this point, your app should be able to display your web page normally.



But don’t get too excited; in this case, native features won’t work

Ionic Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. 
Try removing plugins from plugins/ and reinstalling them
Copy the code

The specific reason is probably the internal mechanism of Cordova.

  1. Is it possible to redirect to an online address on startup?
<script>
    location.href = 'http://192.168.1.148:8000';
</script>
Copy the code

Unfortunately, Android phones will jump straight to the browser to access this address…

Final plan:

Can I change the ionic entry file to an online address? The entry file for ionic is configured in config.xml:

<content src="index.html" />
Copy the code

Let’s make it online

<content src="http://192.168.1.148:8000" />
Copy the code

Success! Native functions are also available. So many detours in one line of code.

Advantages:

Using server deployment can speed up your app deployment updates and avoid the cumbersome process of every release to the app market. Note that if native features are changed, such as adding a new cordova plug-in, you will have to redistribute your installation package.

Disadvantages:

Since all resources are deployed online, your app will display nothing without a network.