AppAvailability is a plugin for Apache Cordova that allows you to check if an app is installed on the user's device. It supports both iOS and Android platforms, utilizing URI schemes for iOS and package names for Android.
Apple changed the canOpenURL method on iOS 9. Apps which are checking for URL Schemes have to declare these Schemes as it is submitted to Apple. The article Quick Take on iOS 9 URL Scheme Changes explains the changes in detail.
canOpenURL
Google introduced a restriction on the QUERY_ALL_PACKAGES permission for apps on the Android operating system. This permission allowed apps to access a broad range of data on a user's device, potentially including sensitive information. However, its unrestricted usage posed privacy and security risks.
To mitigate these risks, Google implemented restrictions on the use of QUERY_ALL_PACKAGES starting with Android 11. Apps targeting this version and higher must adhere to stricter guidelines when requesting this permission. The Google Help Use of the broad package (App) visibility (QUERY_ALL_PACKAGES) permission explains the changes in detail.
Beginning with version 1.0.3 (and OS11_1.0.3) of the plugin, you can now easily add URL Schemes to the -Info.plist file and Android Package Queries to the AndoirdManifest.xml file by using Cordova plugin --variable when integrating the plugin into your application.
cordova plugin add https://github.com/kelter-antunes/AppAvailability.git --variable CORDOVA_ANDROID_QUERIES="com.facebook.android,com.twitter.android" --variable CORDOVA_IOS_URL_SCHEMES="facebook,twitter"
For Android:
--variable CORDOVA_ANDROID_QUERIES="com.facebook.android,com.twitter.android"
Will change the AndroidManifest.xml file to:
<queries> <package android:name="com.facebook.android"/> <package android:name="com.twitter.android"/> </queries>
For iOS:
--variable CORDOVA_IOS_URL_SCHEMES="facebook,twitter"
Will change the -Info.plist file to:
<key>LSApplicationQueriesSchemes</key> <array> <string>facebook</string> <string>twitter</string> </array>
Both variables accept a list of Packages/URL Schemas separated by commas.
In OutSystems you can change the variables in the extensibility configurations:
This plugin enables you to verify if an app is installed on the user's device. It needs a URI Scheme (like twitter://) on iOS or a Package Name (like com.twitter.android) on Android.
Simply run this command to add the latest version of AppAvailability from npm to your project:
$ cordova plugin add cordova-plugin-kelter-appavailability --save
Alternatively, you can install AppAvailability from GitHub:
$ cordova plugin add https://github.com/kelter-antunes/AppAvailability.git --save
appAvailability.check( 'twitter://', // URI Scheme function() { // Success callback console.log('Twitter is available'); }, function() { // Error callback console.log('Twitter is not available'); } );
appAvailability.check( 'com.twitter.android', // Package Name function(info) { // Success callback // Info parameter is available only for android console.log('Twitter is available, and it\'s version is ', info.version); }, function() { // Error callback console.log('Twitter is not available'); } );
var scheme; // Don't forget to add the cordova-plugin-device plugin for `device.platform` if(device.platform === 'iOS') { scheme = 'twitter://'; } else if(device.platform === 'Android') { scheme = 'com.twitter.android'; } appAvailability.check( scheme, // URI Scheme or Package Name function() { // Success callback console.log(scheme + ' is available :)'); }, function() { // Error callback console.log(scheme + ' is not available :('); } );
Twitter:
twitter://
com.twitter.android
Facebook:
fb://
com.facebook.katana
WhatsApp:
whatsapp://
com.whatsapp