nativescript-appavailability icon indicating copy to clipboard operation
nativescript-appavailability copied to clipboard

Breaking on Nativescript 6.5 with Android (Angular)

Open flodaniel opened this issue 5 years ago • 2 comments

plugin lines 5 and 25 :

var pm = com.tns.NativeScriptApplication.getInstance().getPackageManager(); are failing with

TypeError: Cannot read property 'getPackageManager' of null

I worked around it by only using the plugin for ios und using adapting the code for android to the following:

try {
    const pm: android.content.pm.PackageManager = (app.android.context as android.content.Context).getPackageManager();
    pm.getPackageInfo(appName, 0); // will fail, if appName is not installed as package
    isAppAvailable = true;
} catch (error) {
    isAppAvailable = false;
}

flodaniel avatar Jul 03 '20 06:07 flodaniel

Nice! Would you be up for doing a little PR?

EddyVerbruggen avatar Jul 03 '20 08:07 EddyVerbruggen

I will try on the weekend!

flodaniel avatar Jul 03 '20 10:07 flodaniel