skip to Main Content

We have an app on app store and play store , but once user update the app its not working properly ,if user clear the cache and storage it working fine.

we want to check wether user has updated app from app store / play store based on some version number and after that clear the async storage

2

Answers


  1. There’s no way to know that in react native till now, but on the other hand, you can check it using native java for android from here.

    boolean verifyInstallerId(Context context) {
        // A list with valid installers package name
        List<String> validInstallers = new ArrayList<>(Arrays.asList("com.android.vending", "com.google.android.feedback"));
    
        // The package name of the app that has installed your app
        final String installer = context.getPackageManager().getInstallerPackageName(context.getPackageName());
    
        // true if your app has been downloaded from Play Store 
        return installer != null && validInstallers.contains(installer);
    }
    

    and here’s a native solution for IOS using native from this old answer here.

    I prefer you delete the storage for all users in your next update to solve the issue.

    And if you can specify the error you have maybe we can help on it.

    Login or Signup to reply.
  2. In this new version, you can do something like

    const savedVersion = await AsyncStorage.getItem('savedVersion'); // this will return null, because the previous version didn't set this value
    
    const currentVersion = DeviceInfo.getVersion();
    
    if (!savedVersion||semver.lt(savedVersion, currentVersion)) {
      await clearAllStorage();
      await AsyncStorage.setItem('savedVersion', currentVersion);
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search