4

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?

5
  • This will work for you: stackoverflow.com/questions/326069/… Commented Aug 21, 2017 at 23:25
  • @SergioEscudero I was looking for something like this: stackoverflow.com/questions/2400935/… ; but I don't now if WebView can edit User Agent Commented Aug 21, 2017 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. Commented Aug 21, 2017 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 so there is another way? Commented Aug 21, 2017 at 23:37
  • 2
    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...) Commented Aug 22, 2017 at 5:58

0