Answer the question
In order to leave comments, you need to log in
How to direct the user to the application from the mobile version?
Hello, tell me how to implement a block in the mobile version of the site in such a way that the information in it changes depending on the OP of the smartphone.
In other words, you need to show Android users a link to Play.market, and apple users to the app store.
Answer the question
In order to leave comments, you need to log in
If you have a site in a server language (PHP, Python, etc.), then you need to parse the User-Agent header, if SPA, then in navigator.userAgent.
Here is an example from stackoverflow for js
/**
* Determine the mobile operating system.
* This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'.
*
* @returns {String}
*/
function getMobileOperatingSystem() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
// Windows Phone must come first because its UA also contains "Android"
if (/windows phone/i.test(userAgent)) {
return "Windows Phone";
}
if (/android/i.test(userAgent)) {
return "Android";
}
// iOS detection from: http://stackoverflow.com/a/9039885/177710
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
return "iOS";
}
return "unknown";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question