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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-simple-contact

v1.3.8

Published

react native simple contacts library

Downloads

149

Readme

react-native-simple-contact

A simple React Native module to fetch contacts from the user's device with permission handling. This module provides basic functions to request and check permissions, and retrieve contact information, including names and phone numbers.

Installation

1. Install the package

npm install react-native-simple-contact

2. Link the package (for older versions of React Native)

If you're using React Native version 0.59 or earlier, you'll need to link the package manually:

react-native link react-native-simple-contact

For newer versions of React Native, auto-linking should work.

3. Additional setup (iOS)

If you're working on iOS, you may need to add the following to your Info.plist file:

<key>NSContactsUsageDescription</key>
<string>We need access to your contacts to display them in the app.</string>

4. Additional setup (Android)

For Android, ensure that the correct permissions are set in your AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_CONTACTS" />

Usage

Importing the module

import { requestPermission, checkPermission, getContacts, Contact } from "react-native-simple-contact";

Example Usage

Below is an example usage that demonstrates how to request permission, check if permission is granted, and then retrieve contacts:

import React, { useEffect } from "react";
import { Button, Linking, SafeAreaView, StyleSheet, Text, View } from "react-native";
import { requestPermission, checkPermission, getContacts, Contact } from "react-native-simple-contact";

const App = (): JSX.Element => {
  const [contacts, setContacts] = React.useState<Contact[]>([]);
  const [permission, setPermission] = React.useState<boolean>(false);

  const getContactsFetch = async () => {
    // Check permission
    const hasPermission = await checkPermission();
    setPermission(hasPermission);
    
    // Request permission if not granted
    if (!hasPermission) {
      const granted = await requestPermission();
      if (!granted) {
        console.log("Permission denied");
        return;
      }
    }

    // Fetch contacts if permission is granted
    try {
      const contacts = await getContacts();
      setContacts(contacts);
    } catch (error) {
      console.error("Error fetching contacts", error);
    }
  };

  const getPermission = async () => {
    if (!permission) {
      Linking.openSettings();
    }
  };

  useEffect(() => {
    getContactsFetch();
  }, []);

  return (
    <SafeAreaView style={styles.container}>
      {!permission && <Button onPress={getPermission} title="Get Contacts" />}
      {permission &&
        contacts.map((contact, index) => (
          <View key={index}>
            <Text style={styles.text}>{contact?.displayName}</Text>
            <Text style={styles.text}>{contact.phoneNumbers?.[0]?.number}</Text>
          </View>
        ))}
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    padding: 20,
  },
  text: {
    fontSize: 20,
    marginBottom: 20,
  },
});

export default App;

Functions

  1. requestPermission()
    Requests permission from the user to access contacts.

    Returns: Promise<boolean>

    • true: Permission granted.
    • false: Permission denied.
  2. checkPermission()
    Checks if the app has permission to access contacts.

    Returns: Promise<boolean>

    • true: Permission granted.
    • false: Permission denied.
  3. getContacts()
    Fetches the contacts from the device.

    Returns: Promise<Contact[]>

    • Returns an array of contacts with displayName and phoneNumbers.

Contact Object Structure

The Contact object contains the following properties:

interface Contact {
  displayName: string;
  phoneNumbers: Array<{ number: string }>;
}

Troubleshooting

  1. Permission Denied
    If the permission is denied, you can open the app settings for the user to manually enable the permission. You can use the Linking.openSettings() method to open the settings page of the app.

  2. Contacts Not Fetching
    If the contacts are not being fetched, make sure the permissions are correctly set in both iOS (Info.plist) and Android (AndroidManifest.xml).

  3. Missing Contact Details
    Ensure that the contacts on the device have phone numbers, as the phoneNumbers field might be empty for some contacts.

License

MIT