3

I've made a webapp but I don't want that any app load my website in webview.
How can I achieve this?
What can I put into javascript to check if the website is not into a regular browser?

To stop the execution in iframe I use to throw an Error so I just need a condition.

Thanks

PS)

Q: Why you don't just use iframe protection?
A: WebView != iframe

Q: Does the webview have a different User Agent? Or it could be edited too?
A: Yes, It can't be edited on iOS and then detected but it can be edited on android

So... Is the Android WebView a regular browser that can't be detected?

  • This will work for you: https://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t – Sergio Escudero Aug 21 '17 at 23:25
  • @SergioEscudero I was looking for something like this: https://stackoverflow.com/questions/2400935/browser-detection-in-javascript ; but I don't now if WebView can edit User Agent –  Aug 21 '17 at 23:29
  • It is easy enough to restrict your site to your own mobile App. iOS and Android both allow you to set a custom user agent for a webview. Then on your site, if that custom user agent is not found, redirect to a "get the app" page. Not 100% sure to works as some could modify their own user agent to by-pass the check. – Tigger Aug 21 '17 at 23:32
  • @Tiger I don't want to annoy people to download an app for this; so I don't want that other get the website into a webview on android. In android the User Agent can be [edited](https://stackoverflow.com/questions/5586197/android-user-agent#5590105) so there is another way? –  Aug 21 '17 at 23:37
  • 1
    Well, Google stopped allowing OAuth login from a WebView, so it sounds like there is a way to detect it. (You may even be able to hook into Google, by trying to access the Google Login page, and see if an error is returned. Not recommend...) – lionscribe Aug 22 '17 at 05:58

0 Answers0