K
K
Kirill Ivanov2021-06-15 15:56:27
JavaScript
Kirill Ivanov, 2021-06-15 15:56:27

How to determine the type of device from the browser?

Hello!
There is a regular html page with different rates for using one mobile application. And there, accordingly, there are call-to-action buttons, like going to the application or to one of the stores. In this regard, a few questions:

1) if this is a mobile device, how to determine from the browser whether it is android or ios, so that later you can open google play or app store, respectively? The only way I know of is the user-agent, but I read somewhere that in some browsers it gives incorrect information on purpose to protect the user. Are there any other ways?

2) the next task, if the user has this application, you need to open it by clicking on the button on the site. As I understand it, we cannot check the presence of the application from the browser due to security reasons? It remains only to launch the link in the hope that it exists and will start? Or is there something that can be done?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgeny Golubev, 2021-06-16
@bestowhope

The most adequate option if you do not want to dance with a user agent is to give the user a choice. It won't affect anything.
If a person is sitting on an android through a browser that lies that he is a safari, then you will give him a link to the appstore. But he has an android .. How do you decide? - Right. No way.
So just give the person 2 application buttons like they do almost everywhere and don't rack their brains

R
Ronald McDonald, 2021-06-15
@Zoominger

user-agent.
The percentage of users who set themselves crooked user agents (sicurnast, yeah) is negligible compared to the percentage of normal people, so don't worry.

A
Alex, 2021-06-15
@Kozack

Considering the fact that the Safari browser is not cross-platform and is available only on Apple devices, as well as the fact that any browser on Apple devices is just a wrapper around Safari, I believe we can safely say that if a user with Safari comes to you, then is an Apple product user.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question