4

Recently, a few developers have started creating apps which do nothing more than point at state-owned content (free, public property) through UIWebViews. This wouldn't ordinarily be a problem, except the apps are all ad-supported and some are even paid. Essentially, they're making money on state-owned content.

My question is this: how can I force the site to open a new Safari window rather than display in the UIWebview (which is wrapped in their app's branding)? I am able to detect UIWebview using the following, but am unable to do anything besides simply hide the content. I'd prefer it to provide a link to our content which then opens in Safari.

This is how I'm detecting UIWebview:

var is_uiwebview = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);
Ingo Dellwig
  • 226
  • 4
  • 22
Joel Salisbury
  • 175
  • 1
  • 6

3 Answers3

2

unfortunately its fairly trivial for a developer to force the User-Agent string to anything they want, so your attempts to thwart these developers might only be temporary. You can't force your content to be viewed in a browser. A user could use a tool like CURL to view your content also...

CSmith
  • 13,318
  • 3
  • 39
  • 42
  • 1
    True, but through Google Analytics, I suppose we could stay on top of the new user-agents, but that could get pretty unwieldy before long. Isn't this akin to putting an iframe around someone else's content and selling ads on your site? – Joel Salisbury Aug 29 '12 at 14:36
1

Once you detect that you're in the UIWebview, you need to fire a window.open() to put your content in a fresh window.

This talks about some quirks that make it a little tricky (but not impossible): Opening popup links in UIWebview. Note that the question there is the reverse of yours, but the accepted answer does show how to get UIWebview to pop a new window via Javascript.

This has been a concern ever since the Web began. You can't stop people from scraping your content, but you can make it hard to reframe it.

Edited to add

Unfortunately for you, the app can intercept window.open(): UIWebView respond to Javascript calls

I suppose you could always give up and show a banner that says something like "you paid for this data with your taxes, you shouldn't pay for it again with ads. Just open a browser and go to ... "

Community
  • 1
  • 1
egrunin
  • 24,650
  • 8
  • 50
  • 93
  • Thanks for the answer, though it seems like those solutions still cause the link to open in the same UIWebview window. Is it possible the developers have suppressed new windows? – Joel Salisbury Aug 29 '12 at 15:34
1

You can find out if it is a WebView or Mobile Safari, as seen in this thread. The problem is, that you could only open Safari via a custom URL scheme, but think, only http://, https:// etc. work. Even if there would be something like safari-http://, the programmers of the apps with the UIWebView could catch that request and redirect it back into the web view. So, I'm sorry to say: That's not possible.

Community
  • 1
  • 1
Ingo Dellwig
  • 226
  • 4
  • 22