skip to Main Content

I am using webview_flutter package and I want to log the users’ device info for the system Webview version for Android and WkWebView for iOS how can I get the corresponding webview version?

2

Answers


  1. Chosen as BEST ANSWER

    This package fk_user_agent can retrieve user agent which includes info about the web view version

    await FkUserAgent.init();
    String? userAgent = FkUserAgent.webViewUserAgent;
    

  2. Did you try to get the WkWebView version from the user agent string by looking for the string "AppleWebKit/"?

    For example:

    import UIKit
    import WebKit
    
    let webView = WKWebView(frame: .zero)
    let userAgent = webView.value(forKey: "applicationNameForUserAgent") as? String
    var webViewVersion: String?
    
    if let userAgent = userAgent, let range = userAgent.range(of: "AppleWebKit/") {
        let startIndex = range.upperBound
        webViewVersion = String(userAgent[startIndex...])
    }
    
    print("WkWebView version: (webViewVersion ?? "unknown")")
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search