H5 Wake Application Method

Xiaobian to share the H5 awakening method, I hope everyone will read this article, let us discuss together!

H6 evokes this demand for AppPPs. In the era of movement, H6 plays an important role in the APP brings.

Three evilings

The evil way we use is URL Scheme (IOS, Android platform support), just register for scheme when native app development, then users click to this class link When it is automatically jumped to the app.

VAR last = DATE.NOW (), DOC = Window.Document, IFR = Doc.createElement (‘iframe’); // Create a hidden iframeifr.src = nativeurl; IFr.Style.csstext = ‘Display: None; border: 0; width: 0; height: 0;’; doc.body.Appendchild (IFR); settimeout (function () {doc.body.removechild (IFR); / / settimeout back less than 2000 generally to arouse failed IF (Date.Now () – Last
  < 2000) {
        if (typeof onFail == 'function') {
            onFail();
        } else {
            //弹窗提示或下载处理等
        }
    } else {
        if (typeof onSuccess == 'function') {
            onSuccess();
        }
    }
}, 1000); 
The principle of evil start of the IFRAME scheme is that the timer will be postponed (timing) Another situation that is not allowed). If the app is awakened, the web page will inevitably enter the background, if the user cuts back from the app, it will generally exceed 2s; if the app is not evoked, then the web page will not enter the background, setTimeout Basically on time trigger, then time no more than 2s.

window.location.href direct jump

Window.Location
  A tag call  

Evil APP
    Comparison iframe evokes and location.href, we can find:  
For iOS, Location.href jump is more appropriate because this approach can successfully evoke APPs in Safari. Safari is not more to say as the importance of the iPhone default browser, and for WeChat and QQ clients, there is no ovulation in both ways in iOS ==

For Android, in entering page In the case of direct evoke, iframe and location.href are the same, but if it is the evidence of the event driver, the performance of the iframe evoke is better than where location.href is better.

By testing, it can be found that enter the page directly evoke the evil of the event driver. For many browsers, the performance of the two is different, and simply, the failed to evoke more.

Through the above comparison analysis, Android uses iframe evogens, iOS uses window.location.href to evoke more appropriate.

After reading this article, I believe that you have a certain understanding of the H5 awakening app. I want to know more related knowledge. Welcome to Tumi Cloud Industry Information Channel, thank you for reading!

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment