by ohh2ahh
This plugin allows you to check if an app is installed. It requires a package name (e.g com.facebook.katana) on Android or an URI scheme (e.g. fb://) on iOS.
- iOS and Android
- Works with PhoneGap Build (more information)
- Compatible with Plugman and ready for PhoneGap 3.0
window.appavailability('fb://', function(availability) {
// availability is either true or false
if(availability) { console.log('Facebook is available'); }
});
window.appavailability('com.facebook.katana', function(availability) {
// availability is either true or false
if(availability) { console.log('Facebook is available'); }
});
AppAvailability works with PhoneGap build too. You can implement the plugin with these simple steps.
1. Add the following xml to your config.xml
to always use the latest version of this plugin:
<gap:plugin name="com.ohh2ahh.plugins.appavailability" />
or to use this exact version:
<gap:plugin name="com.ohh2ahh.plugins.appavailability" version="0.1.0" />
2. Reference the JavaScript code in your index.html
:
<!-- below <script src="phonegap.js"></script> -->
<script src="js/plugins/AppAvailability.js"></script>
3. Use the plugin as described above.
How do I get the package name / URI scheme?
Facebook:
- Android:
com.facebook.katana
- iOS:
fb://
(and many more asfb://profile
)
Twitter:
- Android:
com.twitter.android
- iOS:
twitter://
(more schemes)
WhatsApp:
- Android:
com.whatsapp
- iOS:
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.