Clear cookies but keep files (#5479)
This commit is contained in:
parent
afe80b6517
commit
f7071c290c
1 changed files with 7 additions and 38 deletions
|
|
@ -6,7 +6,6 @@ import AsyncStorage from '@react-native-community/async-storage';
|
|||
import CookieManager from '@react-native-cookies/cookies';
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import {getLocales} from 'react-native-localize';
|
||||
import RNFetchBlob from 'rn-fetch-blob';
|
||||
|
||||
import {setDeviceDimensions, setDeviceOrientation, setDeviceAsTablet} from '@actions/device';
|
||||
import {selectDefaultChannel} from '@actions/views/channel';
|
||||
|
|
@ -140,44 +139,14 @@ class GlobalEventHandler {
|
|||
|
||||
clearCookiesAndWebData = async () => {
|
||||
try {
|
||||
await CookieManager.clearAll(Platform.OS === 'ios');
|
||||
await CookieManager.clearAll(true);
|
||||
|
||||
if (Platform.OS === 'ios') {
|
||||
// on iOS we will also detele the Cookies stored by NSCookieStore
|
||||
await CookieManager.clearAll(false);
|
||||
}
|
||||
} catch (error) {
|
||||
// Nothing to clear
|
||||
}
|
||||
|
||||
switch (Platform.OS) {
|
||||
case 'ios': {
|
||||
const mainPath = RNFetchBlob.fs.dirs.DocumentDir.split('/').slice(0, -1).join('/');
|
||||
const libraryDir = `${mainPath}/Library`;
|
||||
const cookiesDir = `${libraryDir}/Cookies`;
|
||||
const cookies = await RNFetchBlob.fs.exists(cookiesDir);
|
||||
const webkitDir = `${libraryDir}/WebKit`;
|
||||
const webkit = await RNFetchBlob.fs.exists(webkitDir);
|
||||
|
||||
if (cookies) {
|
||||
RNFetchBlob.fs.unlink(cookiesDir);
|
||||
}
|
||||
|
||||
if (webkit) {
|
||||
RNFetchBlob.fs.unlink(webkitDir);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'android': {
|
||||
const cacheDir = RNFetchBlob.fs.dirs.CacheDir;
|
||||
const mainPath = cacheDir.split('/').slice(0, -1).join('/');
|
||||
const cookies = await RNFetchBlob.fs.exists(`${mainPath}/app_webview/Cookies`);
|
||||
const cookiesJ = await RNFetchBlob.fs.exists(`${mainPath}/app_webview/Cookies-journal`);
|
||||
if (cookies) {
|
||||
RNFetchBlob.fs.unlink(`${mainPath}/app_webview/Cookies`);
|
||||
}
|
||||
|
||||
if (cookiesJ) {
|
||||
RNFetchBlob.fs.unlink(`${mainPath}/app_webview/Cookies-journal`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Nothing to do
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue