Jump to content

Detect with php if WebView (in-app) or mobile browser


Saurabh Jain

Recommended Posts

Posted

How can we check the difference between Android in-app WebView or just the Android browser, same for iOS

I want to hide some Adsense code with php when the website is runned from the in-app webview. But when the app is runned just from the mobile browser it can show Adsense. It’s against the terms and conditions running Adsense in a native WebView app (in-app)

 

This was discussed here https://wordpress.org/support/topic/detect-with-php-if-webview-in-app-or-mobile-browser

and here too http://stackoverflow.com/questions/16383776/detect-in-app-browser-webview-with-php-javascript

Thanks, if found that too, for iOS in-app WebView vs safari mobile browser it's working, but the code for Android is not working..yet :) There are many app in the

 

Can such settings be incorporated in ad settings 

Posted

You haven't really provided much for people to actually help you out, to be honest.

You could always help yourself further by checking why the code isn't working - from what I can see, the code in those links is interrogating the following:

if($_SERVER['HTTP_X_REQUESTED_WITH'] == "com.company.app") {
    echo 'Android (in-app)';
}

So.....if it's not working, test why.....how? Easy - what is the value of:

$_SERVER['HTTP_X_REQUESTED_WITH']

Echo it out to see if it has a value - if it doesn't then that's why it's not working. And if it does have a value, then does it match with the value you think your app has (you haven't stated that yet either)

A good step would be to keep it simple - drop back to a plain old php file which just echoes out content....once you get it working there then you can work on integrating it in to something else.

If you need further assistance then I suggest posting a link to the test/live site you are working on, and show people the actual code you are using....not a link to what you are referrring to, but the actual code you are using.

And then maybe someone can utilise a webview tester to see what is going on.

https://play.google.com/store/apps/details?id=com.piti.webviewtester

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...