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

react-native-android-contactpicker-fixed

v0.5.0

Published

A react-native wrapper for android-contactpicker to facilitate multi-select in one intent

Downloads

4

Readme

react-native-android-contactpicker-fixed

This is a react native module that wraps Android-ContactPicker to facilitate selecting multiple contacts in one intent. This is for android version 5 (or higher) only. Note this is a fork of react-native-android-contactpicker

After upgrading, make sure to clean before compiling: cd android && ./gradlew clean && cd ..

Installation

npm install --save react-native-android-contactpicker-fixed

Usage Example

var ContactPicker = require('react-native-android-contactpicker-fixed')

ContactPicker.open({
  theme: ContactPicker.Themes.LIGHT,
  limit: 20,
  onlyWithPhone: true
})
.then( (contacts) => {
  console.log(contacts)
})
.catch( (err) => {
  console.log(err.code, err.message)
})

/**
Sample contact list:
[
  {
    id: "100",
    name: {
      display:"John Doe",
      first: "John",
      last: "Doe"
    },
    phoneNumbers: [ {"number": "+1-555-555-5555"} ],
    emailAddresses: [ {"email": "[email protected]"} ]
  }
]
**/

Options

| Property | Description | |---|:---| | theme (int) | This option sets the theme for Android-ContactPicker multi-select view only Default: ContactPicker.Themes.LIGHT |
| limit (int) | This parameter will limit the amount of contacts that can be selected per intent. When set to zero, then no limiting will be enforced Default: 0 | | limitReachedMessage (String) | This parameter sets the text displayed as a toast when the set limit is reached Default: You can't pick more than {limit} contacts! | | showCheckAll (Boolean) | This parameter decides whether to show/hide the check_all button in the menu. When limit > 0, this will be forced to false. Default: true | | onlyWithPhone (Boolean) | This parameter sets the boolean that filters contacts that have no phone numbers Default: false |

Constants

ContactPicker.Themes = {
  DARK,
  LIGHT
}

ContactPicker.Errors = {
  UNSUPPORTED,
  USER_CANCEL
}

Getting Started - Android

  • In android/settings.gradle
...
include ':react-native-android-contactpicker-fixed'
project(':react-native-android-contactpicker-fixed').projectDir = new File(settingsDir, '.
./node_modules/react-native-android-contactpicker-fixed/android')
  • In android/app/build.gradle
...
dependencies {
    ...
    compile project(':react-native-android-contactpicker-fixed')
}
  • register module (in android/app/src/main/java/{your-app-namespace}/MainApplication.java)
import com.lwhiteley.reactnativecontactpickerfixed.RNContactPicker; // <------ add import

public class MainApplication extends Application implements ReactApplication {
  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

    ...

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RNContactPicker()
      );
    }
  };

  ...
}
  • Add Contacts permission and Activity (in android/app/src/main/AndroidManifest.xml)
...
  <uses-permission android:name="android.permission.READ_CONTACTS" />
...

<application
     android:name=".MainApplication"
     android:allowBackup="true"
     android:label="@string/app_name"
     android:icon="@mipmap/ic_launcher"
     android:theme="@style/AppTheme">

     ...

        <activity
            android:name="com.onegravity.contactpicker.core.ContactPickerActivity"
            android:enabled="true"
            android:exported="false" >

            <intent-filter>
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </activity>

      ...
</application>

Additional Notes

  • The properties phoneNumbers and emailAddresses will be returned as empty arrays if no phone numbers or emails are found.

Possible Promise Rejection Reasons

The following will cause a rejection that invokes the catch method of the promise that indicates an error (use the console.log to see the specific message):

  1. Android Version below 5.0 is used.

  2. User denies access to the addressbook

  3. User hits the back button and never picks a contact.

Known issues

  • If you select too many contacts, there will be an exception that crashes the app. details. The Best way to avoid this is to limit the amount of contacts a user can select per intent.

Acknowledgements and Special Notes

  • @rhaker's [react-native-select-contact-android](https://github .com/rhaker/react-native-select-contact-android) Issue #5 started the initiative.
  • @1gravity for the awesome library and being open to accepting new features in the Android-ContactPicker library.