darryncampbell / darryncampbell-cordova-plugin-intent

General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.
MIT License
86 stars 130 forks source link

Added packageExists #136

Closed jdgjsag67251 closed 2 years ago

jdgjsag67251 commented 2 years ago

Use case

We would like to know if we are able to start a specific intent before actually calling it. The solution I came up with was checking if the package that exposes the intent is available on the system.

Example

const packageName = 'com.android.contacts';

window.plugins.intentShim.packageExists(packageName, (exists) => {
    if (exists) {
        console.log(`${packageName} exists!`);
    } else {
        console.log(`${packageName} does not exist...`);
    }
});
darryncampbell commented 2 years ago

Reviewed and all looks good, thank you for your contribution.

darryncampbell commented 2 years ago

Posted to npm as 2.2.0