ohh2ahh / AppAvailability

This Cordova / PhoneGap plugin allows you to check if an app is installed.
228 stars 117 forks source link

Not working on Android 11 #68

Closed naresh33 closed 3 years ago

naresh33 commented 3 years ago

Though the app installed on the device, plugin is unable to detect it.

Ionic:

Ionic CLI : 6.16.3 Ionic Framework : @ionic/angular 5.6.11 @angular-devkit/build-angular : 12.1.1 @angular-devkit/schematics : 12.1.1 @angular/cli : 12.1.1 @ionic/angular-toolkit : 4.0.0

Capacitor:

Capacitor CLI : 3.1.1 @capacitor/android : 3.1.2 @capacitor/core : 3.1.1 @capacitor/ios : 3.1.1

System:

NodeJS : v14.17.3 npm : 7.19.1

henkkelder commented 3 years ago

Its not Android 11 that is the problem, but TargetSDKVersion. Since I have set that to 30 the plugin does no longer work in Android. Reverting back to version 29 solves the problem, but doesn't really help since 30 will be neccesary soon.

henkkelder commented 3 years ago

Found the reason: Starting SDK 30 one cannot query all applications anymore, but most specify which application to query in AndroidManifest.xml. This resembles what is needed for IOS in the "LSApplicationQueriesSchemes" element.

I have done this via the following statement in config.xml:

`

`

It was however necessary to update my Android Studio and Gradle to get it working. Otherwise you will get build errors that the element is unknown.

naresh33 commented 3 years ago

Hi @henkkelder

Very thanks.

<queries>
   <package android:name="com.opwekking.liedtekstboek"></package>
</queries> 

Adding the above statement in AndroidManifest.xml solved the issue.

sandhi commented 2 years ago

if you want to get all installed app, try added this to your AndroidManifest.xml file.

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

<queries>
    <intent>
        <action android:name="android.intent.action.MAIN" />
    </intent>
</queries>

I use capacitor and this work as expected, I can get all installed app on the user device.