0

I've got a web-site and a native iOS app, so when someone browses the website version from a iOS mobile phone I add a banner to download the app. Inside the mobile app, some features open an internal webview that shows the website inside the app. I would like to avoid the display of the banner inside the web-view of the native app.

I'm currently recognizing the iPhone like this:

$meta['isIOS'] = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");

Besides adding something to all requests from the native app, is there a way to identify the browsing is done through a web-view of any/my app?

Noam
  • 3,341
  • 4
  • 35
  • 64

2 Answers2

0

I recommend you to check the Mobile-Detect library.

With it you are able to detect what device is loading your page what is its type, OS and etc.

Using such library will remove a lot of problems from your head..

Svetoslav
  • 4,686
  • 2
  • 28
  • 43
  • seems interesting, but not sure, does it allow me to identify between an iphone browser and an iphone in-app webview? – Noam Nov 30 '15 at 13:56
  • If this is the only important thing - http://stackoverflow.com/questions/16383776/detect-in-app-browser-webview-with-php-javascript – Svetoslav Nov 30 '15 at 13:59
0

For your iOS app, you could modify the user agent to include something about your app.

Then check that user agent either in JS or on in server side.

Something like...

let userAgent = UIWebView().stringByEvaluatingJavaScriptFromString("navigator.userAgent")! + " Custom-Agent"
NSUserDefaults.standardUserDefaults().registerDefaults(["UserAgent" : userAgent])
Matt Bryson
  • 2,286
  • 2
  • 22
  • 42