0

Is there any way to read the webview version using JS in Ionic during runtime ?

I want to execute some code blocks based on the WKWebview version in iOS .

if (webview version is > 3.x) {

} else { 
// older webview versions.

}
Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
Vittal Pai
  • 3,317
  • 25
  • 36

1 Answers1

0

Try this.platform.userAgent(), where platform is an instance of import { Platform } from '@ionic/angular';, this should return a string containing the browser details of the environment you are running in.

For example my local browser running the app via ionic serve returned - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36.

You should be able to parse this string to find the relevant details you're after when the app is running in WKWebview.

Simon L. Brazell
  • 1,132
  • 8
  • 14