nativescript-appavailability
nativescript-appavailability copied to clipboard
Breaking on Nativescript 6.5 with Android (Angular)
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;
}
Nice! Would you be up for doing a little PR?
I will try on the weekend!