Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter] Bump minimum Flutter version and iOS deployment target #4361

Merged
merged 3 commits into from
Sep 17, 2021
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
4 changes: 4 additions & 0 deletions packages/webview_flutter/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.14

* Update minimum Flutter SDK to 2.5 and iOS deployment target to 9.0.

## 2.0.13

* Send URL of File to download to the NavigationDelegate on Android just like it is already done on iOS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -597,7 +597,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@ - (void)setUp {
}

- (void)testWebViewWebContentProcessDidTerminateCallsRecourseErrorChannel {
if (@available(iOS 9.0, *)) {
// `webViewWebContentProcessDidTerminate` is only available on iOS 9.0 and above.
WKWebView *webview = OCMClassMock(WKWebView.class);
[self.navigationDelegate webViewWebContentProcessDidTerminate:webview];
OCMVerify([self.mockMethodChannel
invokeMethod:@"onWebResourceError"
arguments:[OCMArg checkWithBlock:^BOOL(NSDictionary *args) {
XCTAssertEqualObjects(args[@"errorType"], @"webContentProcessTerminated");
return true;
}]]);
}
WKWebView *webview = OCMClassMock(WKWebView.class);
[self.navigationDelegate webViewWebContentProcessDidTerminate:webview];
OCMVerify([self.mockMethodChannel invokeMethod:@"onWebResourceError"
arguments:[OCMArg checkWithBlock:^BOOL(NSDictionary *args) {
XCTAssertEqualObjects(args[@"errorType"],
@"webContentProcessTerminated");
return true;
}]]);
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ description: Demonstrates how to use the webview_flutter plugin.
publish_to: none

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.14.0 <3.0.0"
flutter: ">=2.5.0"

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,20 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
}

- (void)clearCookies:(FlutterResult)result {
if (@available(iOS 9.0, *)) {
NSSet<NSString *> *websiteDataTypes = [NSSet setWithObject:WKWebsiteDataTypeCookies];
WKWebsiteDataStore *dataStore = [WKWebsiteDataStore defaultDataStore];

void (^deleteAndNotify)(NSArray<WKWebsiteDataRecord *> *) =
^(NSArray<WKWebsiteDataRecord *> *cookies) {
BOOL hasCookies = cookies.count > 0;
[dataStore removeDataOfTypes:websiteDataTypes
forDataRecords:cookies
completionHandler:^{
result(@(hasCookies));
}];
};

[dataStore fetchDataRecordsOfTypes:websiteDataTypes completionHandler:deleteAndNotify];
} else {
// support for iOS8 tracked in https://github.com/flutter/flutter/issues/27624.
NSLog(@"Clearing cookies is not supported for Flutter WebViews prior to iOS 9.");
}
NSSet<NSString *> *websiteDataTypes = [NSSet setWithObject:WKWebsiteDataTypeCookies];
WKWebsiteDataStore *dataStore = [WKWebsiteDataStore defaultDataStore];

void (^deleteAndNotify)(NSArray<WKWebsiteDataRecord *> *) =
^(NSArray<WKWebsiteDataRecord *> *cookies) {
BOOL hasCookies = cookies.count > 0;
[dataStore removeDataOfTypes:websiteDataTypes
forDataRecords:cookies
completionHandler:^{
result(@(hasCookies));
}];
};

[dataStore fetchDataRecordsOfTypes:websiteDataTypes completionHandler:deleteAndNotify];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,14 @@ - (void)onRemoveJavaScriptChannels:(FlutterMethodCall*)call result:(FlutterResul
}

- (void)clearCache:(FlutterResult)result {
if (@available(iOS 9.0, *)) {
NSSet* cacheDataTypes = [WKWebsiteDataStore allWebsiteDataTypes];
WKWebsiteDataStore* dataStore = [WKWebsiteDataStore defaultDataStore];
NSDate* dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
[dataStore removeDataOfTypes:cacheDataTypes
modifiedSince:dateFrom
completionHandler:^{
result(nil);
}];
} else {
// support for iOS8 tracked in https://github.com/flutter/flutter/issues/27624.
NSLog(@"Clearing cache is not supported for Flutter WebViews prior to iOS 9.");
}
NSSet* cacheDataTypes = [WKWebsiteDataStore allWebsiteDataTypes];
WKWebsiteDataStore* dataStore = [WKWebsiteDataStore defaultDataStore];
NSDate* dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
[dataStore removeDataOfTypes:cacheDataTypes
modifiedSince:dateFrom
completionHandler:^{
result(nil);
}];
}

- (void)onGetTitle:(FlutterResult)result {
Expand Down Expand Up @@ -391,25 +386,18 @@ - (void)updateAutoMediaPlaybackPolicy:(NSNumber*)policy
case 0: // require_user_action_for_all_media_types
if (@available(iOS 10.0, *)) {
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
} else if (@available(iOS 9.0, *)) {
configuration.requiresUserActionForMediaPlayback = true;
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
configuration.mediaPlaybackRequiresUserAction = true;
#pragma clang diagnostic pop
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g Sep 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: We could cut down on warnings for users who build for 10+ as a minimum by moving these pragmas to the iOS 9 code instead of removing them entirely.

configuration.requiresUserActionForMediaPlayback = true;
}
break;
case 1: // always_allow
if (@available(iOS 10.0, *)) {
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
} else if (@available(iOS 9.0, *)) {
configuration.requiresUserActionForMediaPlayback = false;
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
configuration.mediaPlaybackRequiresUserAction = false;
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
#pragma clang diagnostic pop
} else {
configuration.requiresUserActionForMediaPlayback = false;
}
break;
default:
Expand Down Expand Up @@ -468,11 +456,7 @@ - (void)registerJavaScriptChannels:(NSSet*)channelNames
}

- (void)updateUserAgent:(NSString*)userAgent {
if (@available(iOS 9.0, *)) {
[_webView setCustomUserAgent:userAgent];
} else {
NSLog(@"Updating UserAgent is not supported for Flutter WebViews prior to iOS 9.");
}
[_webView setCustomUserAgent:userAgent];
}

#pragma mark WKUIDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Downloaded by pub (not CocoaPods).
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'

s.platform = :ios, '8.0'
s.platform = :ios, '9.0'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
end
6 changes: 3 additions & 3 deletions packages/webview_flutter/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: webview_flutter
description: A Flutter plugin that provides a WebView widget on Android and iOS.
repository: https://github.com/flutter/plugins/tree/master/packages/webview_flutter/webview_flutter
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 2.0.13
version: 2.0.14

environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0"
sdk: ">=2.14.0 <3.0.0"
flutter: ">=2.5.0"

flutter:
plugin:
Expand Down