ios – No comand found with name “clearCache” on react-native-webview

[ad_1]

I am implementing a method to clear the webview cache in a react-native application. However, when running the application under development after construction, on iOS the error is displayed with the message: “No command found with name ‘clearCache'”.

This error only happens on iOS, on Android everything seems fine.

 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
    }
  }

There is nothing in the terminal log, i.e. the catch is not triggered.

Expo:

expo error screen

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
}

Testing on iOS 17.1 and 16.4.1(a)
Expo latest version

[ad_2]

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top