Open p206ab opened 4 years ago
First off you are trying to remove it in the wrong platform being smartwebview. You should be identifying what platforms are viewing your site (computer browser, mobile phone, smartwebview app, etc) server side and handling it there. I suggest have smartwebview generate a cookie, exactly like it does when it sends gps coordinates to your site if you have them enabled. Server side with whatever language you are using php,node.js, etc whatever you would then either look to see if the cookie is set or holds whatever data you have assigned to the cookie. If this cookie matches your condition you know a device is utilizing the site via smartwebview. At that time you can disable the header with javascript on the site or through whatever other means. Think of it this way....your site should tailor how its displayed to either a mobile device or computer. This is no different. You just need to add the functionality in to detect smartwebview and display the site how you want it to look in smartwebview.
@djmike3404 is possibly telling the best way to handle the issue, use a custom cookie to set on onCreate()
and check it on your server end, if it satisfies the condition hide the header with CSS.
Thanks @djmike3404 for a great solution, didn't think of that... anyhow it solved the issue, adding the code for anyone stumbling on the same issue:
`$iPhoneBrowser = stripos($_SERVER['HTTP_USER_AGENT'], "iPhone"); $iPadBrowser = stripos($_SERVER['HTTP_USER_AGENT'], "iPad"); $AndroidBrowser = stripos($_SERVER['HTTP_USER_AGENT'], "Android"); $AndroidApp = $_SERVER['HTTP_X_REQUESTED_WITH'] == "com.company.app"; $iOSApp = (strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile/') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari/') == false);
if ($AndroidApp) { echo "Put here something, js, css or something"; } else if ($AndroidBrowser) { echo "This is Android browser, show Android app banner"; } else if ($iOSApp) { echo "This is iOS application, DONT SHOW BANNER"; } else if($iPhoneBrowser || $iPadBrowser) { echo "This is iOS browser, show iOS app banner"; }`
Thanks @djmike3404 for a great solution, didn't think of that... anyhow it solved the issue, adding the code for anyone stumbling on the same issue:
`$iPhoneBrowser = stripos($_SERVER['HTTP_USER_AGENT'], "iPhone"); $iPadBrowser = stripos($_SERVER['HTTP_USER_AGENT'], "iPad"); $AndroidBrowser = stripos($_SERVER['HTTP_USER_AGENT'], "Android"); $AndroidApp = $_SERVER['HTTP_X_REQUESTED_WITH'] == "com.company.app"; $iOSApp = (strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile/') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari/') == false);
if ($AndroidApp) { echo "Put here something, js, css or something"; } else if ($AndroidBrowser) { echo "This is Android browser, show Android app banner"; } else if ($iOSApp) { echo "This is iOS application, DONT SHOW BANNER"; } else if($iPhoneBrowser || $iPadBrowser) { echo "This is iOS browser, show iOS app banner"; }`
No problem @p206ab. Happy to help
I've been using this repo which works great and I love the feature of a side menu drawer. Since I'm using that, the header on my website is now obsolete and I would like to force remove it.
I've been trying many different options inside onPageFinished function (line 596 of MainActivity), but non of them seems to be working, example:
public void onPageFinished(WebView view, String url) { print_page(view,view.getTitle(),false); view.loadUrl("javascript:document.getElementById('header').style.display='none';"); super.onPageFinished(view, url); }
Any ideas how to achieve that? Thanks.