Share.isPackageInstalled (Android only)
It's a simple method that check if a package-name is installed with the Intent on Android. Similar to Share.open and Share.single this method will return a Promise, which will be fulfilled when the native code successfully check for the application.
Using a promise implementation:
Share.isPackageInstalled('com.instagram.android')
.then((response) => {
console.log(response);
// Check response.isInstalled for the boolean result.
})
.catch((error) => {
console.log(error);
// { error }
});
Or with async/await:
const checkPackage = async () => {
const { isInstalled } = await Share.isPackageInstalled('com.instagram.android');
}
Don't forget to add queries for Android SDK >= 30. Check package visibility on Android.
Keep in mind, that similar to Share.open and Share.single it's a good idea using a try/catch whenever a call to this method is requested.
For iOS you can use Linking.canOpenURL('instagram://'), where the URL is the app scheme that you want to check. Also, calling isPackageInstalled on iOS rejects with Error: Not implemented.