John Davidson

php - Is there any way to get the id of "Android WebView" app?

0 comments
Message:


I use this php code to check if the user open my website from a Webview or from a browser and i want to get the id of "Android App WebView" apk which is on the playstore
but i don't find it and i also want the id of "Google Chrome" apk.
Id example: "com.facebook.orca".


if($_SERVER['HTTP_X_REQUESTED_WITH'] == "com.facebook.orca")
echo 'var isWebView=true;';
else
echo 'var isWebView=false;';


My Answer:
Unfortunately, there is no direct way to get the id of the "Android WebView" app or the "Google Chrome" app using PHP code. The HTTP_X_REQUESTED_WITH header typically contains the package name of the app making the request, but this header is not always reliable and may not contain the information you are looking for.

If you specifically need to detect if the user is using a WebView or a browser, you can try checking the user agent string instead. The user agent string for WebView may contain the word "WebView" or "Android" in it. However, this method is also not foolproof as user agent strings can be easily manipulated.

If you absolutely need to get the package name of the app making the request, you may need to consider using a different approach such as creating a custom Android app that sends additional information in the request headers or using JavaScript to detect the app and send the information to your PHP script.

Rate this post

3 of 5 based on 4866 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us