我正在实现一个方法来清除react-native应用程序中的webview缓存。然而,当在构建后运行正在开发的应用程序时,在iOS上显示错误消息:“No command found with name 'clearCache'”。
这个错误只发生在iOS上,在Android上一切似乎都很好。
async function checkAndUpdateAppVersion(pCallBack) {
const currentBuildVersion = nativeBuildVersion;
const previousBuildVersion = await AsyncStorage.getItem("buildVersion");
try {
if (currentBuildVersion !== previousBuildVersion) {
//AsyncStorage.setItem("buildVersion", currentVersion);
const { clearCache } = webviewRef.current;
clearCache && clearCache(true);
}
} catch (error) {
console.warn(error);
} finally {
pCallBack && pCallBack(); // Executa o callback caso exista
}
}
字符串
终端日志中没有任何内容,即catch没有被触发。
展会:
x1c 0d1x的数据
Package.json:
{
"name": "investira.vc.native",
"version": "2.0.1",
"scripts": {
"start": "npx expo start",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"eject": "expo eject",
"clean:cache": "expo r -c",
"build:ios": "eas build --platform ios",
"build:android": "eas build --platform android",
"build:hmg:ios": "eas build --platform ios --profile homolog",
"build:hmg:android": "eas build --platform android --profile homolog",
"submit:ios": "eas submit --platform ios"
},
"dependencies": {
"@expo/config-plugins": "^7.2.5",
"@react-native-async-storage/async-storage": "1.18.2",
"dotenv": "^16.0.3",
"expo": "^49.0.16",
"expo-application": "~5.3.0",
"expo-asset": "~8.10.1",
"expo-build-properties": "^0.8.3",
"expo-local-authentication": "~13.4.1",
"expo-splash-screen": "~0.20.5",
"expo-status-bar": "~1.6.0",
"expo-system-ui": "~2.4.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.6",
"react-native-safe-area-context": "4.6.3",
"react-native-status-bar-height": "^2.6.0",
"react-native-web": "~0.19.6",
"react-native-webview": "^13.6.2"
},
"devDependencies": {
"@babel/core": "^7.18.6"
},
"private": true
}
型
在iOS 17.1和16.4.1(a)Expo最新版本上测试
1条答案
按热度按时间c8ib6hqw1#
尝试使用此https://github.com/react-native-webview/react-native-webview/issues/2625的单独软件包
个字符