Skip to content

Modified how webkit cookies are deleted in the clearAll method #152

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 11 additions & 8 deletions ios/RNCookieManagerIOS/RNCookieManagerIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,17 @@ + (BOOL)requiresMainQueueSetup
if (useWebKit) {
if (@available(iOS 11.0, *)) {
dispatch_async(dispatch_get_main_queue(), ^(){
// https://stackoverflow.com/questions/46465070/how-to-delete-cookies-from-wkhttpcookiestore#answer-47928399
NSSet *websiteDataTypes = [NSSet setWithArray:@[WKWebsiteDataTypeCookies]];
NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes
modifiedSince:dateFrom
completionHandler:^() {
resolve(@(YES));
}];
NSSet *dataTypesToRetrieve = [NSSet setWithArray:@[ WKWebsiteDataTypeCookies ]];
[[WKWebsiteDataStore defaultDataStore] fetchDataRecordsOfTypes:dataTypesToRetrieve
completionHandler:^(NSArray<WKWebsiteDataRecord *> * _Nonnull records) {
NSSet *cookieDataType = [NSSet setWithArray:@[ WKWebsiteDataTypeCookies ]];
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:cookieDataType
forDataRecords:records
completionHandler:^{
resolve(@(YES));
}
];
}];
});
} else {
reject(@"", NOT_AVAILABLE_ERROR_MESSAGE, nil);
Expand Down