AppAvailability for iOS and Android
A Plugin for Apache Cordova and Adobe PhoneGap by ohh2ahh.
- Some URI Schemes / Package Names
Important: iOS 9 URL Scheme Whitelist
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 expains the changes in detail.
Add URL Schemes to the Whitelist
Simply open your app's .plist (usually
platforms/ios/<appname>/<appname>-Info.plist) with an editor and add the following code with your needed Schemes.
This plugin allows you to check if an app is installed on the user's device. It requires an URI Scheme (e.g. twitter://) on iOS or a Package Name (e.g com.twitter.android) on Android.
- Ready for the Command-line Interface of Cordova / PhoneGap 3.0 and later
- Works with PhoneGap Build (more information)
The Cordova CLI is the recommended way to install AppAvailability, see The Command-line Interface. You can find the plugin on these registries:
- Cordova Plugin Registry (deprecated in favor of npm)
- PhoneGap Plugin Registry (deprecated because updating a plugin on PhoneGap Build requires a paid plan now)
Automatically (Command-line Interface)
Simply run this command to add the latest version of AppAvailability from npm to your project:
$ cordova plugin add cordova-plugin-appavailability
Don't forget to prepare and compile your project:
$ cordova build
Alternatively you can install AppAvailability from GitHub:
$ cordova plugin add https://github.com/ohh2ahh/AppAvailability.git
AppAvailability works with PhoneGap build too. Unfortunately PhoneGap Build requires now a paid plan to update a plugin. Therefore the version on PhoneGap Build is deprecated.
You can implement version
0.3.1 of the plugin by adding the following xml to your
Or if you want to use the exact version of AppAvailability:
You can find a PhoneGap Build project which demonstrates AppAvailability in the repository ohh2ahh/AppAvailability-Demo-PhoneGap-Build.
❗️ The code changed in version 0.3.0 and supports now success and error callbacks! But you can still use the old approach, which is described below.
var scheme;// Don't forget to add the org.apache.cordova.device plugin!ifdeviceplatform === 'iOS'scheme = 'twitter://';else ifdeviceplatform === 'Android'scheme = 'com.twitter.android';appAvailability;
Old Approach (AppAvailability < 0.3.0)
The only thing you have to do is replacing
4. Some URI Schemes / Package Names
fb://(and many more as
whatsapp://(only since v. 2.10.1, more information)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.