background
Quick application document
In March 2018, 10 domestic mainstream manufacturers such as Xiaomi, OPPO, Vivo and Huawei established the Fast Application Alliance, which unified the technical specifications and ensured that the fast application developed by developers could run directly on the mobile devices of all manufacturers in the alliance. Fast application is a direct application between web and native, direct to users, without the need to install app, can form a seamless connection between user needs and application services at the operating system level, many functions only used in native applications can be easily realized in the fast application.
This is the introduction of the fast application document, looks very good is not, the native is too heavy, the web page can call the system level of things too little, the technical level of the fast application of both advantages have. However, because the performance of each manufacturer is not completely consistent, and even the version is not consistent, the problem can be found on the Internet to a clear answer is also very few, and some have been outdated, so in the development of fast application and docking process, really stepped on a lot of pits. It is Now February 2022, and the latest version of the Fast Application platform is version 1100. Note some of the problems encountered.
Quick application and H5 communication
The main use is web components, Web components quick application is used to embed H5 links. Establish a bridge between H5 and kapp, and then communicate, enabling H5 to invoke the capabilities of kapp to operate. The communication here is similar to iframe communication. H5 can use System. onMessage to monitor and receive messages sent by the express application, system.postMessage to send messages to the express application, push and monitor the received messages for processing. Web components. Fast applications need to process messages asynchronously after receiving them, perform the desired operations, and invoke the related capabilities of fast applications.
H5 Quick hop application mode
Js jump
Loading js, using the js method to jump, method mounted under the window, no window object, such as small programs want to jump fast application may not be able to do
<script type="text/javascript" src="//statres.quickapp.cn/quickapp/js/routerinline.min.js"></script>
appRouter(pkgName, quickappPath,{url})
Copy the code
Deeplink jump
Deeplink supported formats
Low http://hapjs.org/app/ < package > / / path /? Key = value "https://hapjs.org/app/ < package > / / path? Key = value low Hap ://app/<package>/[path][? Key =value] ● hwFastApp ://<package>/[path][? Key =value] // This mode is supported only by HuaweiCopy the code
The difference between the two jump modes
ChannelReady checks the fast application capability. If the fast application service is supported, the value will be returned as true; otherwise, the value will be returned as false. However, true does not necessarily mean that the jump will succeed. Huawei always returns true, but not all of them will be successful
channelReady &&
channelReady(bAvailable= > {
// Whether the model supports fast application
if (bAvailable) {
// The appRouter method will jump to deeplink at the same time -- dplink will jump to test js directly
/ / deeplink jump
window.location.href = `hap://app/${pkgName}/${quickappPath}? url=The ${encodeURIComponent(url)}`
/ / js jump
appRouter(pkgName, quickappPath, {url})
} else {
window.location.href = 'xxxx' // Jump to the bottom page}})Copy the code
Huawei’s JS jump is limited,Click to see the document Huawei JS only supports kirin chip models jump…
However, if you want to go through the whole process of h5 to jump to the quick app, some js models will jump directly to the official quick app. Deeplink will ask what loader to use before jumping to the quick app. Deeplink will make it easier to test. The test process does not jump directly to the formal fast application environment. Write deeplink and JS jump at the same time, some models may jump twice.
Jump Mode Compatibility
- The hop modes supported by vendors in different channels are inconsistent
- The performance within each app may also be inconsistent (wechat/Alipay/browser)
- If the parameter is too long, the jump may fail, and the manufacturer, model, channel, and jump mode are inconsistent. Js jumps may fail, and Deeplink has a total length limit of 932 bytes
Deeplink-stitched URL paths need to be transcoded, otherwise some models will fail to load
For example, if you want to load an H5 page through webView in the quick application, h5 jumps to the quick application with embedded WebView, dPLink passes the parameter URL = XXX through key=value. In some models, this link needs to be transcoded, otherwise the blank screen will be loaded. Note that only the encode URL is required when the deeplink method jumps.
A blank screen appears on some models when loading fast apps
Fast application platform version
Some of the problems encountered above are basically caused by other models other than Huawei, huawei can basically go through the normal process, the official version is also the latest version. In particular, it should be noted that the versions of other manufacturers’ quick application platforms are basically lower than those of Huawei. For example, the latest version of Huawei Quick Application is 1100, but the official versions of Xiaomi and Vivo are basically 1090+, which have not been updated to the latest version. So if you use the features of the 1100 version of the words must be degraded judgment processing, otherwise in the Millet and other models will directly appear fast application loading white screen. Pay attention to the version of some features during development. For example, downloadtask is a new feature added to 1100. If you use it directly, a blank screen will be loaded for faster applications of earlier versions. You can perform compatibility degradation by obtaining the platform version based on device information.
Pay special attention to the differences between Huawei and other vendors
- Fast application loaders are available for testing, while other vendors only have fast application debuggers and fast application previews
- Js only supports kirin chip jump, deeplink hap mode is not effective in wechat, HTTP/HTTPS transfer page is actually through loading JS jump, so the performance is consistent with JS
- Huawei supports some apis earlier than the alliance document. For example, Huawei 1070 supports downloadTask, and other vendors only support downloadTask 1100.