How to read Ionic Webview version in Javascript?

1.1k Views Asked by At

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.

}
1

There are 1 best solutions below

1
Simon L. Brazell On

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.