Closed jsligh closed 3 months ago
I am actually quite stumped on this because of the following:
The current implementation MUST include a completion handler in WKWebView.evaluateJavascript
but we can't wait for it to complete because synchronously waiting on the main thread will block the completion handler from ever executing.
self.userAgent = [self.webView valueForKey:@"userAgent"];
while synchronous, is an undocumented API which we cannot guarantee will always work/be correct.
We cannot use ASYNC AWAIT or a similar concurrent Swift function as it is too new (iOS 15+). This will not work as the minimum target version for GMA SDK is iOS 12.0.
Convert PBMUserAgentService
to Swift and use ASYNC AWAIT for clients > iOS 15.0 and keep the current method for clients on older versions.
Rewrite implementation and put in some kind of wait for all clients.
PBMUserAgentService
.
Fixes #938
Removes the race condition and uses UIWebView instead of WKWebView. UIWebView does javascript calls synchronously while WKWebView does javascript asynchronously which is why the race condition is occurring. While synchronous execution might take an extra second, it prevents a lot of headaches and dispatch_once makes sure this only happens once. The UserAgent is also cached in the shared PBMUserAgentService.