6

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)

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Chu Việt Hưng
  • 141
  • 1
  • 1
  • 8
  • Shouldn't it be `.isAppInstalledAndroid('skype')` instead? Since the `pkgName` is already defined in the app-list object. source: https://github.com/redpandatronicsuk/react-native-check-app-install/blob/master/app-list.js – Ray May 16 '17 at 21:46
  • I tried react-native-check-app-install and fail because it really buggy :) At first I decided to fix some bugs but at the end I just installed react-native-shared-group-preferences and forget about react-native-check-app-install :) – Stich Sep 17 '21 at 15:20

4 Answers4

4
  1. Google Play considers the list of installed apps to be personal and sensitive user data.

As we are using

AppInstalledChecker
    .isAppInstalledAndroid()

method for checking app installed check, for that we have to white-list the queries in manifest.xml

Reference : https://developer.android.com/training/package-visibility

<queries>
    <package android:name="com.instagram.android"/>
    …
</queries>
  1. For adding Queries need to upgrade build gradle version: new default settings and features for package visibility in Android 11 that need to add  you must update your android gradle plugin version

Reference: How to fix "unexpected element <queries> found in <manifest>" error?

I have updated from 3.5.2 to 4.0.2

Now react-native-check-app-install module working as expected

Hope this is resolved!

3

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
    }
}
Hamidreza Sadegh
  • 2,155
  • 31
  • 33
0

Android

I. For app's which has deep links like 'waze://', 'mapsme://' you can use:

import { Linking } from 'react-native'
...
Linking.canOpenURL('waze://ul?ll=${latitude},${longitude}&navigate=yes')

OR

II. You can use for absolutely all apps (for example with deep links like "https://...") https://github.com/KjellConnelly/react-native-shared-group-preferences

iOS

import { Linking } from 'react-native'
...
Linking.canOpenURL(iOS_app_URL_Scheme)
...

where iOS_app_URL_Scheme you can find via Google for each separate app. Like "waze://", "comgooglemaps://", "osmandmaps://" etc

Stich
  • 2,331
  • 1
  • 15
  • 31
0

For expo managed workflow, you can create an Expo plugin that adds the necessary tag. This is the code in case it helps anyone:

const { withAndroidManifest } = require('@expo/config-plugins');

module.exports = function androidManifestPlugin(config) {
  return withAndroidManifest(config, (config) => {
    let androidManifest = config.modResults.manifest;

    androidManifest.queries.push({
      package: {
        $: {
          'android:name': 'com.whatsapp',
        },
      },
    });

    console.log('androidManifest', androidManifest);
    return config;
  });
};

This will add the following tag:

<queries>
    <package android:name="com.whatsapp"/>
</queries>

You can then check the existence of the application by:

const exists = await Linking.canOpenURL('whatsapp://send?text=Hello')