What should I do if the APP interface version is not compatible? Teach you a trick

Now basically every company does APP, so everyone is facing the problem of APP interface version compatibility.

iOS and android are constantly developing new versions, and many server developments are modified on the logic of the previous interface. After the development of the new APP and interface, how is the interface compatible with the old APP?

Some companies force users to update to the latest version each time they publish the app. This is not recommended because the user experience is too bad.

Even with forced updates, the new APP interface and the old interface must be available at the same time during Apple's review.

Below we talk about how to do it, everyone has different opinions can leave a message to discuss.

First, the client is compatible, the interface does not need to be compatible.

1. APP forced update (not recommended)

Interface URL: api.xxx.com/v1.0/xxxx.java

Add the version number to the URL of the interface, as above: v1.0.

The update is forced each time a new APP version is released.

The grayscale server deploys the version of the interface being audited (for example: v1.1). After the review is passed, the old version of the APP settings is forced to update, so the old interface is no longer needed.

Then redeploy the online server to the latest code and remove the grayscale server.

This way the APP interface accesses the official online server.

2, hot update

Urgent small needs can be updated with hot, large demand suggestions or native code, because you have modified with hot updates (using JS or Lua), and finally modified in the native code.

Online games use more hot updates, because the online game APP is too large, it is impossible to add a small level to require users to re-download, and the game update is more frequent than the enterprise-level APP, with hot updates can continue to add new levels, scenarios, activities promotion .

What should I do if the APP interface version is not compatible? Teach you a trick

3. React NaTIve and Weex

Weex is better than React NaTIve and I suggest you try it. Personal advice is not to use them extensively. After all, they are only third-party things, and some things are not perfect.

Second, the server is version compatible

Whether all interface versions are unified:

All interfaces use the same version number: this way to send a new version of the APP to modify the version number, modify it, but if you want to modify the version number of one of the interfaces, it will not work.

The version number of each interface can be different: this is more flexible and is recommended.

Because I have not done the server for many years. If there are errors in the following insights, I hope to correct them.

1, each interface logic plus if judge (not recommended)

Interface URL: api.xxx.com/api? Version=v1&..

If (version == '1.5.0') {

Do_something

} else if (version =='1.4.0') {

Do_something

}

Advantages: simple implementation

Disadvantages: The logic of different versions is in one method, which is easy to cause code confusion and is not conducive to maintenance.

2, different folders

Equivalent to each interface version is a separate project. Put it in a separate folder on the server.

E.g:

Interface URL: api.xxx.com/v1.0/xxxx.php

Folder location: Controller/V1.0/

-----------------/xxxx.php

Folder location: Controller/V2.1/

-----------------/xxxx.php

Advantages: Version logic is maintained separately. Look at the url to know which version. Remove the extra version without modifying the code.

Disadvantages: Different versions of the same interface are duplicated. And if there is a problem with the previous versions of the interface, and have been left to the present, you need to change several sets of the same code.

3. Different versions use different methods:

similar:

Interface URL: api.xxx.com/v1.0/xxxx.php

Class XXXX{

Public funcTIonV1_0() { }

Public funcTIonV2_0() { }

}

Java or C# has a routing configuration, you can use the routing configuration different versions of the URL to jump to a different method.

4, using the way of inheritance

"A bottle of true feelings" replies in the comments: Inheritance, you can use the previous interface code, you can also use the override method to modify the implementation of some interfaces.

This is ok. But if your previous version (that is, the parent class) modified the code, it will affect all subsequent versions.

It is very likely that the base class will be modified when there are bugs or changes in requirements on the line.

You can discuss it.

5, deploy to different servers

"xuanbg" replied in the comments:

Different versions of different branches are deployed on different servers. If a version is not used, just kill the service.

For example, if my API is going to be upgraded from 1.x to incompatible version 2.0, then I will give a tag to the current release branch. When the 1.x version of the API requires a fix bug, it can be easily released from the tag of the 1.x branch after the fix bug, and the branch will not be merged into any branch, so it will not affect Other versions.

The downside of this solution is that if 2.0 has the same bug, it should be changed on the 2.0 branch. If there are a lot of versions, this will not work well. Therefore, it is generally not possible to release more than two versions at the same time. Before upgrading the incompatible third version, the first version will be killed.

But for example, Taobao, WeChat, and sometimes forget to update, you will find that Taobao has upgraded 4 or 5 versions, and then the old version can still be used. That is, some apps do need to be compatible with 4 or 5 versions.

In addition, if you want to be compatible with too many versions, the server needs to be enough. At the same time, because the old version of the people use less, that is, some servers have very few visits, and some have a lot of server access. Can't really load balance, wasting server resources.

6, mixed use

"Tokyo^hot" said in the reply that a mixture of the two methods is used. Several methods of server side are mixed:

6.1. The third method is used together with the fourth method. Inherit first, if the new version and the previous version can not be reused, use the route to set a new method.

6.2. The first method is used together with the third method. The simple small change is judged by the first type and an if. Use the third one to change the larger one, and open a new method.

Third, the end

I have not been a server for several years. If you have any good ideas, you can leave a message, thank you.

Interface compatibility is mainly a server-side task. The workload of the APP is relatively simple.

How do everyone do it?

Main Marine Diesel Generator

Main Marine Diesel Generator,Off Shore Diesel Generator,Platform Marine Generator,Marine Propulsion Engine

Jiangsu Vantek Power Machinery Co., Ltd , https://www.vantekpower.com

Posted on