npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-appavailability-patch

v0.6.1

Published

This plugin for Cordova and PhoneGap allows you to check if an app is installed. It requires an URI Scheme (iOS) or a Package Name (Android).

Downloads

36

Readme

AppAvailability for iOS and Android

GitHub version npm version

A Plugin for Apache Cordova and Adobe PhoneGap by ohh2ahh.

  1. Description
  2. Installation 2. Automatically (Command-line Interface) 2. PhoneGap Build
  3. Usage 3. iOS 3. Android 3. Full Example 3. Old Approach (AppAvailability < 0.3.0)
  4. Some URI Schemes / Package Names
  5. License

Important: iOS 9 and iOS 10 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.

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>twitter</string>
    <string>whatsapp</string>
</array>

1. Description

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

Supported Platforms

  • iOS
  • Android

2. Installation

The Cordova CLI is the recommended way to install AppAvailability, see The Command-line Interface. You can find the plugin on these registries:

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 --save

Don't forget to prepare and compile your project:

$ cordova prepare
$ cordova build

You don't have to reference the JavaScript in your index.html.

Alternatively you can install AppAvailability from GitHub:

$ cordova plugin add https://github.com/ohh2ahh/AppAvailability.git --save

PhoneGap Build

AppAvailability works with PhoneGap build too. You can include this plugin from either npm or directly from this repository:

<plugin name="cordova-plugin-appavailability" source="npm" />
<plugin spec="https://github.com/ohh2ahh/AppAvailability.git" source="git" />

There is no need to reference the JavaScript in your index.html.

3. Usage

:exclamation: 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.

iOS

appAvailability.check(
    'twitter://', // URI Scheme
    function() {  // Success callback
        console.log('Twitter is available');
    },
    function() {  // Error callback
        console.log('Twitter is not available');
    }
);

Android

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');
    }
);

Full Example

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 :(');
    }
);

Old Approach (AppAvailability < 0.3.0)

The only thing you have to do is replacing appAvailability.check with appAvailability.checkBool:

appAvailability.checkBool('twitter://', function(availability) {
    // availability is either true or false
    if(availability) { console.log('Twitter is available'); }
});

4. Some URI Schemes / Package Names

How do I get the URI Scheme / Package Name?

Twitter:

  • iOS: twitter://
  • Android: com.twitter.android

Facebook:

  • iOS: fb://
  • Android: com.facebook.katana

WhatsApp:

5. License

The MIT License (MIT)

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.