File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -92,8 +92,18 @@ - (void)initWebview:(FlutterMethodCall*)call {
9292 }
9393
9494 if (clearCookies != (id )[NSNull null ] && [clearCookies boolValue ]) {
95- [[NSURLSession sharedSession ] resetWithCompletionHandler: ^{
96- }];
95+ if (@available (iOS 9.0 , *)) {
96+ NSSet *websiteDataTypes
97+ = [NSSet setWithArray: @[
98+ WKWebsiteDataTypeCookies ,
99+ ]];
100+ NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970: 0 ];
101+
102+ [[WKWebsiteDataStore defaultDataStore ] removeDataOfTypes: websiteDataTypes modifiedSince: dateFrom completionHandler: ^{
103+ }];
104+ } else {
105+ // Fallback on earlier versions
106+ }
97107 }
98108
99109 if (userAgent != (id )[NSNull null ]) {
@@ -217,7 +227,13 @@ - (void)closeWebView {
217227- (void )reloadUrl : (FlutterMethodCall*)call {
218228 if (self.webview != nil ) {
219229 NSString *url = call.arguments [@" url" ];
220- NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString: url]];
230+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: url]];
231+ NSDictionary *headers = call.arguments [@" headers" ];
232+
233+ if (headers != nil ) {
234+ [request setAllHTTPHeaderFields: headers];
235+ }
236+
221237 [self .webview loadRequest: request];
222238 }
223239}
You can’t perform that action at this time.
0 commit comments