lucasferreira / react-native-send-intent

React Native Android module to use Android's Intent actions for send text to shareable apps or make phone calls or opening third party apps
419 stars 159 forks source link

Not working on Android 10 onwards #151

Open niyasali64 opened 1 year ago

niyasali64 commented 1 year ago
SendIntentAndroid.isAppInstalled("com.myapp2").then(isInstalled => {
    console.log('is Installed---->', isInstalled)
    if (isInstalled) {
        SendIntentAndroid.openApp("com.myapp2", {
            "com.myapp2.reason": "just because",
            "com.myapp2.data": "must be a string",
        }).then(wasOpened => {
            console.log('wasOpened------->', wasOpened)

        });
    }
    else {
        Linking.openURL(
            'https://play.google.com/store/apps/details?id=com.myapp2',
            );
    }
});

The App2 is installed, Working on up to Android 9. But afterward not working, it is going to the play store link,

SaGaR1084 commented 1 year ago

@niyasali64 Can you please try this in AndroidManifest.xml it's working for me after adding this

 <queries>
        <package android:name="com.test.yourapp" />
 </queries>
joao-gabriel-gois commented 11 months ago

I'm facing the same. isInstalled is returning false for known installed apps.

1mike12 commented 8 months ago

From GPT4 summarizing something that I loosely remembered:

starting with Android 10 (API level 29), Google introduced additional restrictions and changes regarding privacy and how apps can interact with other apps installed on the same device. One of the key changes affects an app's ability to query the presence of other apps on the device. This change was implemented as part of Android's ongoing efforts to enhance user privacy.

Querying Installed Apps Restriction

Before Android 10, apps could freely query the list of installed apps on a device. This capability could be used for various purposes, such as checking for the presence of companion apps, competitive analysis, or feature enhancement based on available apps. However, this could also potentially be exploited to gather information about the user without their knowledge.

With Android 10, Google restricted this capability. Apps now need to declare specific permissions in their manifest file to query installed apps. Specifically, apps must declare the QUERY_ALL_PACKAGES permission in their AndroidManifest.xml file to query any app that's installed on the device, not just those that they can interact with directly.

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>

Implications

Best Practices

Developers are encouraged to minimize their use of the QUERY_ALL_PACKAGES permission and only request it when absolutely necessary for the app's function. Instead of querying all apps, developers can use more specific intents and queries for interacting with other apps, such as using Intent filters to discover apps that can perform a specific action (e.g., opening an email client) without needing to know all apps installed on the device.

For opening an email client, as discussed earlier, using an intent with the action Intent.ACTION_SENDTO and a mailto URI (mailto:) is a privacy-friendly approach that doesn't require querying installed apps and is compliant with Android 10's privacy enhancements.