There is an app on Google Play which is embedding my website in a webview. The app does nothing else, and includes a 3rd party monetization feature.
I want to detect when users are accessing my site via the app, so that I can show a message.
I haven't however been able to find a way to distinguish between the Android mobile browser and the app, as the user agents are the same.
Is there any known method to detect a webview?
Thanks.
Unfortunately, the answer is no, there isn't a way to distinguish between the Android mobile browser and another webview-based app.
Unless the app developer elects to modify the user agent, of course.
If you know the App ID of the app displaying your website through a webview, you can use PHP to detect if your site is being accessed through the app rather than a mobile browser by using the $_SERVER
global array.
<?php
$app_id = "com.domain.appname";
$using_app = ( $_SERVER['HTTP_X_REQUESTED_WITH'] == $app_id ) ? TRUE: FALSE;
if ( $using_app ) {
echo "Using app message.";
}
?>
You can then use the $using_app
variable to control content output and display a custom message.
This is all assuming of course you are server scripting your site via PHP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With