There is an "open now" button on the current page. If you have installed an app, you can call the corresponding app to open it. Otherwise, you will be redirected to the download page. Method 1 found on the scheme network of the known app: {code ...} method 1 does not work, and the logs on the page are always found on the "not installed app" website... there is an "open now" button on the current page. If you have installed an app, you can call the corresponding app to open it. Otherwise, you will be redirected to the download page.
Scheme of a known app
Method 1 found on the Internet:
$ (Document). ready (function () {var log = function (msg) {$ ('body'). before (''+ Msg +'
') ;}; Var timeout, t = 1000, hasApp = true; setTimeout (function () {if (hasApp) {log ('app installed ');} else {log ('app not installed ') ;}}, 2000); function testApp () {var t1 = Date. now (); var ifr = $ (''); ifr. attr ('src', 'diaodiao: // '); $ ('body '). append (ifr); // after insertion, the try_to_open_app method timeout = setTimeout (function () {try_to_open_app (t1) ;}, t) ;} function try_to_open_app (t1) is executed after Ms) {var t2 = Date. now (); If (! T1 | t2-t1 <t + 200) {hasApp = false ;}} testApp ();});
Method 1 does not work, and the log on the page is always "not installed"
Method 2:
Window. onload = function () {function isInstalled () {var originHref = location. href; var url = originHref. substring (originHref. indexOf ('//') + 2); var schemeUrl = "diaodiao: //" + url; window. location = schemeUrl; // open an app setTimeout (function () {window. location = "http://a.app.qq.com/o/simple.jsp? Pkgname = com. diaox2.android & ckey = CK1308661595241 "; // jump to the app download page if the timeout occurs}, 20000);} var downlink = document. querySelector ('. downlink '); downlink. addEventListener ('click', function () {isInstalled () ;}, false )}
The problem with this method is,window.location=schemeUrl;After the code is executed, a dialog box pops up in safari asking if you want to use the corresponding app to open it, and then jump to the download link (isn't it scheduled? I don't know why the timer doesn't work ?)
----------------- New -------------------
The above two methods certainly have their applicability period. These solutions are at least a year ago. With the updates of IOS/Android systems and browsers, they are no longer applicable .. When using iframe to call an app, I can call it in safari under IOS8.3, but safari under 9.2.1 cannot. It cannot be tested in Android5.0.1, and can only be called in Android Chrome ..
I met a guy who thought like me, but didn't seem to have a good answer.
How to open the app through scheme in the browser in ios9
----------------- New -------------------
Finally solved (although not so elegant, not covering all browsers or webviews), wrote a document:
Determine whether to install the app in the browser
At the same time, thank you for your comments!
Reply content:
There is an "open now" button on the current page. If you have installed an app, you can call the corresponding app to open it. Otherwise, you will be redirected to the download page.
Scheme of a known app
Method 1 found on the Internet:
$ (Document). ready (function () {var log = function (msg) {$ ('body'). before (''+ Msg +'
') ;}; Var timeout, t = 1000, hasApp = true; setTimeout (function () {if (hasApp) {log ('app installed ');} else {log ('app not installed ') ;}}, 2000); function testApp () {var t1 = Date. now (); var ifr = $ (''); ifr. attr ('src', 'diaodiao: // '); $ ('body '). append (ifr); // after insertion, the try_to_open_app method timeout = setTimeout (function () {try_to_open_app (t1) ;}, t) ;} function try_to_open_app (t1) is executed after Ms) {var t2 = Date. now (); If (! T1 | t2-t1 <t + 200) {hasApp = false ;}} testApp ();});
Method 1 does not work, and the log on the page is always "not installed"
Method 2:
Window. onload = function () {function isInstalled () {var originHref = location. href; var url = originHref. substring (originHref. indexOf ('//') + 2); var schemeUrl = "diaodiao: //" + url; window. location = schemeUrl; // open an app setTimeout (function () {window. location = "http://a.app.qq.com/o/simple.jsp? Pkgname = com. diaox2.android & ckey = CK1308661595241 "; // jump to the app download page if the timeout occurs}, 20000);} var downlink = document. querySelector ('. downlink '); downlink. addEventListener ('click', function () {isInstalled () ;}, false )}
The problem with this method is,window.location=schemeUrl;After the code is executed, a dialog box pops up in safari asking if you want to use the corresponding app to open it, and then jump to the download link (isn't it scheduled? I don't know why the timer doesn't work ?)
----------------- New -------------------
The above two methods certainly have their applicability period. These solutions are at least a year ago. With the updates of IOS/Android systems and browsers, they are no longer applicable .. When using iframe to call an app, I can call it in safari under IOS8.3, but safari under 9.2.1 cannot. It cannot be tested in Android5.0.1, and can only be called in Android Chrome ..
I met a guy who thought like me, but didn't seem to have a good answer.
How to open the app through scheme in the browser in ios9
----------------- New -------------------
Finally solved (although not so elegant, not covering all browsers or webviews), wrote a document:
Determine whether to install the app in the browser
At the same time, thank you for your comments!
In other words, iframe is usually used in ios to open your scheme address. location. href is usually used in Android...
But the actual situation seems to be much more complicated than this ....
The landlord can refer to this: http://js.40017.cn/touch/hb/p/openApp.js
No tests
First, propose a possible solution.
Asynchronously request scheme to obtain the status code. (Solution established IF scheme has a status code)
OrYou can ignore whether the app is opened normally.
Use iframeTryWhen scheme uri is enabled, no matter it is unsuccessful, a download app is displayed.
Please ask, what you wrote
SetTimeout (function (){
var timeOutDateTime = new Date();if (!loadDateTime || timeOutDateTime - loadDateTime < 1010) { window.location = self.dataset.href;}
},1000 );
Window. location = 'diaodiao ://';
Where is loadDateTime defined? Is there a complete definition?
About iOS9,
Recently, I used my webapp to pack it with phonegap, and then I want to determine whether the app is installed on my mobile phone. If so, I need to be able to directly jump into the app from the content page, in addition, the alert box cannot be seen.
It is OK in iOS9, as long as there is an https connection that apple can approve. The keyword is Universal Link. NetEase news uses this method. After testing, it can basically meet the judgment requirement.