Skip to content

[webview_flutter_wkwebview] Fixes bug where WebkitWebViewController.getUserAgent was incorrectly returning an empty String #5062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.9.1

* Fixes bug where `WebkitWebViewController.getUserAgent` was incorrectly returning an empty String.

## 3.9.0

* Adds support for `PlatformWebViewController.getUserAgent`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ Future<void> main() async {

final String? userAgent = await controller.getUserAgent();
expect(userAgent, isNotNull);
expect(userAgent, isNotEmpty);
});

group('Video playback policy', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,10 @@ window.addEventListener("error", function(e) {
@override
Future<String?> getUserAgent() async {
final String? customUserAgent = await _webView.getCustomUserAgent();
if (customUserAgent != null) {
// Despite the official documentation of `WKWebView.customUserAgent`, the
// default value seems to be an empty String and not null. It's possible it
// could depend on the iOS version, so this checks for both.
if (customUserAgent != null && customUserAgent.isNotEmpty) {
return customUserAgent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview
description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control.
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_wkwebview
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 3.9.0
version: 3.9.1

environment:
sdk: ">=2.19.0 <4.0.0"
Expand Down