Recently, we are making such a function. When the front-end webpage clicks the button, if the user's mobile phone has the app installed, the app will be opened directly; otherwise, it will jump to the application market to download. The code is as follows:
The above code is divided into ios, Android and wechat built-in browser. The implementation method is window.location.href ="xxx: / /"; first try to wake up the app in the phone through the protocol. If the jump is successful within 2000ms, it means that the app has been installed in the phone and opened directly. The following timer code will not be executed. If it is still on this page after more than 2000 ms, it is proved that the user's mobile phone does not have an app installed, then the code in the timer will be executed and the user will jump to the application market to download.
Burn goose, when I finished this, the boss suddenly said to add a function like this: if your mobile phone has already installed this app, then the "open client" above will be changed to "open app". If it is not installed, then the word "download app" will be prompted. Then I frowned. Whether to install the app or not was not realized through judgment... Then I, as a workplace young Mengxin, shivered back to my seat and began to look for relevant information. After a lot of efforts, I didn't ~ ~ ~ and then I asked several senior brothers who had already worked. They also said that only the front-end is difficult to achieve. It is suggested that the back-end judge and return the results to me....
So now the second function has not been realized. Welcome to let me know if you have any ideas ~ ~ thank you!