KiperTecnologia / react-native-kiper-contacts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-kiper-contacts

Warning

- This library is available only for android, ios library in construction!! - If you want use for ios, try this library: https://github.com/rt2zz/react-native-contacts/

Getting started

$ npm install react-native-kiper-contacts --save or yarn add react-native-kiper-contacts

Mostly automatic installation

$ react-native link react-native-kiper-contacts

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import br.com.kiper.contact.KiperContactsPackage; to the imports at the top of the file
  • Add new KiperContactsPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-kiper-contacts'
    project(':react-native-kiper-contacts').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-kiper-contacts/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      implementation project(':react-native-kiper-contacts')
    

Usage

tip: Always check permission for readContacts :)

import kiperContacts from 'react-native-kiper-contacts';

const getAllExample = async () => {
  const result = await kiperContacts.getAll(0, 0);
  // result = [{ name: string, phones: [array of strings], contactId: string }]
};

const searchContactsExample = async () => {
  // types: like, like left, like right or null(null = equals)
  const filters = [{ key: 'name', value: 'test', type: 'like' }];
  const result = await kiperContacts.searchContacts(filters, 0, 0);
  // result = [{ name: string, phones: [array of strings], contactId: string }]
};

Example

https://github.com/KiperTecnologia/contactsExample

Credits

www.kiper.com.br

About

License:MIT License


Languages

Language:Java 91.3%Language:Ruby 5.0%Language:Objective-C 2.7%Language:JavaScript 0.9%