From 312655329d48612701f769cc5dae877250ae0641 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 12 Dec 2018 07:09:15 +1300 Subject: [PATCH 1/3] Update InAppBrowserWebViewController.swift --- .../InAppBrowserWebViewController.swift | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ios/Classes/InAppBrowserWebViewController.swift b/ios/Classes/InAppBrowserWebViewController.swift index 4c5ae31a..5c1e682a 100644 --- a/ios/Classes/InAppBrowserWebViewController.swift +++ b/ios/Classes/InAppBrowserWebViewController.swift @@ -64,10 +64,10 @@ window.\(JAVASCRIPT_BRIDGE_NAME).callHandler = function(handlerName, ...args) { } """ -func currentTimeInMilliSeconds() -> Int { +func currentTimeInMilliSeconds() -> Int64 { let currentDate = Date() let since1970 = currentDate.timeIntervalSince1970 - return Int(since1970 * 1000) + return Int64(since1970 * 1000) } func convertToDictionary(text: String) -> [String: Any]? { @@ -168,7 +168,7 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU var isHidden = false var uuid: String = "" var WKNavigationMap: [String: [String: Any]] = [:] - var startPageTime = 0 + var startPageTime: Int64 = 0 var viewPrepared = false required init(coder aDecoder: NSCoder) { @@ -609,9 +609,9 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU if (webViewOptions?.useOnLoadResource)! { if let url = navigationResponse.response.url { if WKNavigationMap[url.absoluteString] != nil { - let startResourceTime = (WKNavigationMap[url.absoluteString]!["startTime"] as! Int) - let startTime = startResourceTime - startPageTime; - let duration = currentTimeInMilliSeconds() - startResourceTime; + let startResourceTime: Int64 = (WKNavigationMap[url.absoluteString]!["startTime"] as! Int64) + let startTime: Int64 = startResourceTime - startPageTime; + let duration: Int64 = currentTimeInMilliSeconds() - startResourceTime; self.didReceiveResourceResponse(navigationResponse.response, fromRequest: WKNavigationMap[url.absoluteString]!["request"] as? URLRequest, withData: Data(), startTime: startTime, duration: duration) } } @@ -701,7 +701,7 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU } } - func didReceiveResourceResponse(_ response: URLResponse, fromRequest request: URLRequest?, withData data: Data, startTime: Int, duration: Int) { + func didReceiveResourceResponse(_ response: URLResponse, fromRequest request: URLRequest?, withData data: Data, startTime: Int64, duration: Int64) { if navigationDelegate != nil { navigationDelegate?.onLoadResource(uuid: self.uuid, webView: webView, response: response, fromRequest: request, withData: data, startTime: startTime, duration: duration) } @@ -750,8 +750,8 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU if !UIApplication.shared.canOpenURL(url) { return } - let startTime = Int(resource["startTime"] as! Double) - let duration = Int(resource["duration"] as! Double) + let startTime = Int64(resource["startTime"] as! Double) + let duration = Int64(resource["duration"] as! Double) var urlRequest = URLRequest(url: url) urlRequest.allHTTPHeaderFields = [:] let config = URLSessionConfiguration.default From 54faefe23f23db703c6b3661327b613a0664d3dc Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 12 Dec 2018 07:10:16 +1300 Subject: [PATCH 2/3] Update InAppWebView.swift --- ios/Classes/InAppWebView.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/Classes/InAppWebView.swift b/ios/Classes/InAppWebView.swift index 2fcf2ca3..772ef2ff 100644 --- a/ios/Classes/InAppWebView.swift +++ b/ios/Classes/InAppWebView.swift @@ -15,7 +15,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi var options: InAppWebViewOptions? var currentURL: URL? var WKNavigationMap: [String: [String: Any]] = [:] - var startPageTime = 0 + var startPageTime: Int64 = 0 init(frame: CGRect, configuration: WKWebViewConfiguration, IABController: InAppBrowserWebViewController?, IAWController: FlutterWebViewController?) { super.init(frame: frame, configuration: configuration) @@ -449,9 +449,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi if (options?.useOnLoadResource)! { if let url = navigationResponse.response.url { if WKNavigationMap[url.absoluteString] != nil { - let startResourceTime = (WKNavigationMap[url.absoluteString]!["startTime"] as! Int) - let startTime = startResourceTime - startPageTime; - let duration = currentTimeInMilliSeconds() - startResourceTime; + let startResourceTime: Int64 = (WKNavigationMap[url.absoluteString]!["startTime"] as! Int64) + let startTime: Int64 = startResourceTime - startPageTime; + let duration: Int64 = currentTimeInMilliSeconds() - startResourceTime; onLoadResource(response: navigationResponse.response, fromRequest: WKNavigationMap[url.absoluteString]!["request"] as? URLRequest, withData: Data(), startTime: startTime, duration: duration) } } @@ -520,7 +520,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi getChannel().invokeMethod("onProgressChanged", arguments: arguments) } - public func onLoadResource(response: URLResponse, fromRequest request: URLRequest?, withData data: Data, startTime: Int, duration: Int) { + public func onLoadResource(response: URLResponse, fromRequest request: URLRequest?, withData data: Data, startTime: Int64, duration: Int64) { var headersResponse = (response as! HTTPURLResponse).allHeaderFields as! [String: String] headersResponse.lowercaseKeys() @@ -613,8 +613,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi if !UIApplication.shared.canOpenURL(url) { return } - let startTime = Int(resource["startTime"] as! Double) - let duration = Int(resource["duration"] as! Double) + let startTime: Int64 = Int64(resource["startTime"] as! Double) + let duration: Int64 = Int64(resource["duration"] as! Double) var urlRequest = URLRequest(url: url) urlRequest.allHTTPHeaderFields = [:] let config = URLSessionConfiguration.default From 2812726655271f723f4c1f8980208deee5677847 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 12 Dec 2018 07:10:53 +1300 Subject: [PATCH 3/3] Update SwiftFlutterPlugin.swift --- ios/Classes/SwiftFlutterPlugin.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/SwiftFlutterPlugin.swift b/ios/Classes/SwiftFlutterPlugin.swift index 14dd4b0d..30ef86ba 100644 --- a/ios/Classes/SwiftFlutterPlugin.swift +++ b/ios/Classes/SwiftFlutterPlugin.swift @@ -734,7 +734,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin { } } - func onLoadResource(uuid: String, webView: WKWebView, response: URLResponse, fromRequest request: URLRequest?, withData data: Data, startTime: Int, duration: Int) { + func onLoadResource(uuid: String, webView: WKWebView, response: URLResponse, fromRequest request: URLRequest?, withData data: Data, startTime: Int64, duration: Int64) { if self.webViewControllers[uuid] != nil { var headersResponse = (response as! HTTPURLResponse).allHeaderFields as! [String: String] headersResponse.lowercaseKeys()