How can i check app installed in react native code

2019-05-30 11:01发布

问题:

i tried to check other app install in my react native project, I'm used module like: https://www.npmjs.com/package/react-native-check-app-install But always got this error: Cannot read property 'pkgName' of undefined Here is my code:

    AppInstalledChecker
    .isAppInstalledAndroid('com.skype.raider') 
    .then((isInstalled) => {
        // isInstalled is true if the app is installed or false if not 
         console.log('App Skype status: ', isInstalled);
    });

Anyone can suggest me one way so check app install in react native (both: iOS/android)

回答1:

install this

https://github.com/KjellConnelly/react-native-shared-group-preferences

and

async check() {
    try {
        await SharedGroupPreferences.isAppInstalledAndroid("com.farsitel.bazaar")
        // IF IS INSTALL
    } catch (e) {
        // IF IS NOT INSTALL
    }
}