Skip to content

Instantly share code, notes, and snippets.

@berga
Forked from chrisallick/uiwebview_snippet.js
Created February 1, 2018 12:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berga/22867433a7e8d780b5596c4aaf3b9dc4 to your computer and use it in GitHub Desktop.
Save berga/22867433a7e8d780b5596c4aaf3b9dc4 to your computer and use it in GitHub Desktop.
JavaScript only solution for detecting UIWebView.
// http://stackoverflow.com/questions/4460205/detect-ipad-iphone-webview-via-javascript
var standalone = window.navigator.standalone,
userAgent = window.navigator.userAgent.toLowerCase(),
safari = /safari/.test( userAgent ),
ios = /iphone|ipod|ipad/.test( userAgent );
if( ios ) {
if ( !standalone && safari ) {
//browser
} else if ( standalone && !safari ) {
//standalone
} else if ( !standalone && !safari ) {
//uiwebview
};
} else {
//not iOS
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment