我如何检查安装在反应本机代码中的应用程序

Chu*_*ưng 6 react-native

我尝试检查我的 React Native 项目中的其他应用程序安装,我使用的模块如下:https: //www.npmjs.com/package/react-native-check-app-install 但总是收到此错误:无法读取属性未定义的“pkgName”这是我的代码:

    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);
    });
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议我一种方法,以便在 React Native 中检查应用程序安装(两者:iOS/Android)

kon*_*mar 5

    \n
  1. Google Play 认为已安装应用程序列表是\xc2\xa0个人和敏感用户数据。
  2. \n
\n

正如我们正在使用的

\n
AppInstalledChecker\n    .isAppInstalledAndroid()\n
Run Code Online (Sandbox Code Playgroud)\n

检查应用程序安装检查的方法,为此我们必须将manifest.xml中的查询列入白名单

\n

参考: https: //developer.android.com/training/package-visibility

\n
<queries>\n    <package android:name="com.instagram.android"/>\n    \xe2\x80\xa6\n</queries>\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  1. 要添加查询,需要升级构建 gradle 版本:\n\xc2\xa0 包可见性\xc2\xa0in\xc2\xa0Android 11\xc2\xa0 的新默认设置和功能,需要添加\xc2\xa0\xc2\xa0,您必须更新您的 android gradle插件版本
  2. \n
\n

参考:如何修复“在 <manifest> 中找到意外元素 <queries>”错误?

\n

我已经从3.5.2更新到4.0.2

\n

现在,react-native-check-app-install模块按预期工作

\n

希望这个问题能够得到解决!

\n

上面的链接现在应该可以工作(必须添加这句话,这样我才能满足编辑限制的最小长度)

\n


Ham*_*egh 3

安装这个

https://github.com/KjellConnelly/react-native-shared-group-preferences
Run Code Online (Sandbox Code Playgroud)

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

  • ios呢? (2认同)