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

alphacontact-contacts-package

v1.0.10

Published

Un module pour récupérer des informations à partir des contacts du carnet d'adresses du téléphone Android.

Downloads

2

Readme

AlphaContact Contacts Package

Important Note: This module is ready to be used in your projects, however, please be aware that it is not yet optimized for regular updates. Future changes may require adjustments in your code. We are actively working to improve the stability and maintainability of the module for future versions.

En français

A module to retrieve information from the contacts in the Android phone address book.

Installation

You can install this module using npm. Make sure you have Node.js and npm installed on your system.

npm install *******

  1. Locate the ContactsModule.java and ContactsPackage.java files within the alphacontact-contacts package.

  2. Copy the folder /contacts folder.

  3. Navigate to your project's android/app/src/main/java/com/youtProject directory.

  4. Paste the com/alphacontact/contacts folder inside the java directory. Make sure the folder structure looks like this:

|-- src
    |-- main
        |-- java
            |-- com
                |-- yourProject
                    |-- contacts

                    MainApplication.java

In the MainApplication.java file, add the import statement: import com.alphacontact.contacts.ContactsPackage; at the beginning of the file, right after the other import statements. Then, in the getPackages() method, add packages.add(new ContactsPackage()); to include the ContactsPackage package in your project. Here's the complete code:

package com.yourproject;

import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.alphacontact.contacts.ContactsPackage; // Import the ContactsPackage package here

import java.lang.reflect.InvocationTargetException;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      packages.add(new ContactsPackage()); // Add this line to include the ContactsPackage package
      return packages;
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

With these modifications, the ContactsPackage package will be added to the project, and you'll be able to use the ContactsModule module in your React Native application. Remember to follow the installation steps for the module mentioned earlier so that the com/alphacontact/contacts folder is placed in the correct location in the Android project.

Certainly! If your project is named "MyAwesomeApp," you need to replace all occurrences of com.alphacontact.contacts with com.myawesomeapp.contacts in both the MainApplication.java and ContactsModule.java files. Here's the updated code:

In ContactsModule.java and ContactsPackage.java:

package com.alphacontact.contacts; // Replace "alphacontact" with "myawesomeapp"

In MainApplication.java:

package com.myawesomeapp; // Replace "alphacontact" with "myawesomeapp"

// ... Other import statements ...

import com.myawesomeapp.contacts.ContactsPackage; // Replace "alphacontact" with "myawesomeapp"

import java.lang.reflect.InvocationTargetException;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  // ... Rest of the code ...

Please make sure to rename the package correctly based on your project's name, and ensure that the ContactsModule.java file is placed in the appropriate folder within your project's Android module.

Supported Versions

This module is compatible with Android versions 4.0 (Ice Cream Sandwich) and above.

Requirements

Node.js (version 12 or above) React Native (version 0.66.0 or above)

Available Functions

getAllContacts(promise: Promise)

This function retrieves all contacts from the address book and returns an array of contacts with their information, including phone numbers, email addresses, groups they belong to, contact photo, birthday, and other information.

getAllGroups(promise: Promise)

This function retrieves all groups from the address book and returns an array containing the names of these groups.

getContactsByGroup(groupName: string, promise: Promise)

This function retrieves contacts belonging to a specific group based on the group name provided as a parameter. It returns an array of contacts with their information, including phone numbers and email addresses.

getPhoneNumber(contactId: string): string

This function takes the ID of a contact (contactId) as a parameter and returns its associated phone number. If the phone number is not available or an error occurs, it will return null.

getPhoneNumbers(contactId: string): string[]

This function takes the ID of a contact (contactId) as a parameter and returns an array containing all phone numbers associated with that contact. If no phone numbers are available or an error occurs, it will return an empty array.

getEmailAddresses(contactId: string): string[]

This function takes the ID of a contact (contactId) as a parameter and returns an array containing all email addresses associated with that contact. If no email addresses are available or an error occurs, it will return an empty array.

getGroupsForContact(contactId: string): string[]

This function takes the ID of a contact (contactId) as a parameter and returns an array containing the names of the groups that contact belongs to. If the contact does not belong to any groups or an error occurs, it will return an empty array.

Usage

To use this module in your React Native application, you can import it as follows:

import { NativeModules } from 'react-native';
const { ContactsModule } = NativeModules;

Then, you can call the available functions of the module, for example:

ContactsModule.getAllContacts()
  .then((contacts) => {
    console.log('Contacts:', contacts);
  })
  .catch((error) => {
    console.error('Error:', error);
  });
import { getAllContacts, getAllGroups, getContactsByGroup } from 'alphacontact-contacts-package';

// Exemple : Récupérer tous les contacts
getAllContacts().then((contacts) => {
  console.log(contacts);
}).catch((error) => {
  console.error(error);
});

// Exemple : Récupérer tous les groupes
getAllGroups().then((groups) => {
  console.log(groups);
}).catch((error) => {
  console.error(error);
});

// Exemple : Récupérer les contacts d'un groupe spécifique
const groupName = 'Amis';
getContactsByGroup(groupName).then((contacts) => {
  console.log(contacts);
}).catch((error) => {
  console.error(error);
});

Notes

  • Make sure your Android application has the necessary permissions to access the phone's address book, such as READ_CONTACTS.
  • Some information may not be available for certain contacts, depending on permissions and data entered by the user.