0

I'm advertising that there's a web application also avalaible of my website. The add is unnecessary if the user is already using the app. So is there anyway to check that with php/html?

  • What kind of 'web application'? In other words, does it run as PHP code on a server? Is it a windows application? What kind? Where will the user run it? On the same machine as where the browser receiving the output of your PHP code runs? Etc. – KIKO Software Jan 07 '18 at 07:46
  • I've made the website with php and converted it to app with appsgeyser. The user is running it with a mobile phone – Marianne Sjöberg Jan 07 '18 at 08:06
  • Possible duplicate of https://stackoverflow.com/questions/16383776/detect-in-app-browser-webview-with-php-javascript – David Jan 07 '18 at 08:34
  • Possible duplicate of [Detect in-app browser (WebView) with PHP / Javascript](https://stackoverflow.com/questions/16383776/detect-in-app-browser-webview-with-php-javascript) – iainn Jan 07 '18 at 11:27

1 Answers1

2

If you mean that you want to check if the user is using a webview (from app Android/iOS) instead of a desktop, mobile browser, then you can check the user agent string

https://developer.chrome.com/multidevice/user-agent#webview_user_agent

If you’re attempting to differentiate between the WebView and Chrome for Android, you should look for the presence of the Version/X.X string in the WebView user-agent string. Don’t rely on the specific Chrome version number (for example, 30.0.0.0) as the version numbers changes with each release.

You could apparently use the same approach for iOS Does UIWebView send the same User-Agent in the Request Headers as mobile Safari?

Get the user agen in PHP

$user_agent = $_SERVER['HTTP_USER_AGENT'];

UPDATE:

Have a look there, there is some more explanations Detect in-app browser (WebView) with PHP / Javascript

David
  • 33,444
  • 11
  • 80
  • 118
  • Still not sure how to check if user is using the app or web browser with mobile phone..? What should I check from the string $_SERVER['HTTP_USER_AGENT']? – Marianne Sjöberg Jan 07 '18 at 08:25
  • The user agent is a string which contains different values depending on what browser is used. So, you just need to search for that specific string. For chrome Lollipop, you can search for the 'wv' string (according to the 1st link). You'll have to use regular expressions for the other ones – David Jan 07 '18 at 08:31
  • I added a link to another post.. which might be a duplicate of yours – David Jan 07 '18 at 08:34
  • but is an android app using actually chrome as a browser? if that's so then this isn't helping me.. – Marianne Sjöberg Jan 07 '18 at 08:35
  • Webviews are based on Chromium since android 4.4. https://developer.chrome.com/multidevice/webview/overview And they add specific details on the user agent string, as indicated in the 1st link. – David Jan 07 '18 at 08:47
  • So if the user is using the app with Android phone there's 'wv' string. And if the user is using the app with iPhone then there's not 'Safari' string. Is that so? And what if the user is using the app with Windows phone? – Marianne Sjöberg Jan 07 '18 at 09:33