react-native-contacts
Advanced tools
Comparing version 3.1.4 to 3.1.5
111
index.d.ts
@@ -1,61 +0,60 @@ | ||
declare module 'react-native-contacts' { | ||
export function getAll(callback: (error: any, contacts: Contact[]) => void): void; | ||
export function getAllWithoutPhotos(callback: (error: any, contacts: Contact[]) => void): void; | ||
export function getPhotoForId(contactId: string, callback: (error: any, photoUri: string) => void): void; | ||
export function addContact(contact: Contact, callback: (error?: any) => void): void; | ||
export function openContactForm(contact: Contact, callback: (error: any, contact: Contact) => void): void; | ||
export function openExistingContact(contact: Contact, callback: (error: any, contact: Contact) => void): void; | ||
export function updateContact(contact: Contact, callback: (error?: any) => void): void; | ||
export function deleteContact(contact: Contact, callback: (error?: any) => void): void; | ||
export function getContactsMatchingString(str: string, callback: (error: any, contacts: Contact[]) => void): void; | ||
export function checkPermission(callback: (error: any, result: 'authorized' | 'denied' | 'undefined') => void): void; | ||
export function requestPermission(callback: (error: any, result: 'authorized' | 'denied' | 'undefined') => void): void; | ||
export function writePhotoToPath(contactId: string, file: string, callback: (error: any, result: boolean) => void): void; | ||
export function getAll(callback: (error: any, contacts: Contact[]) => void): void; | ||
export function getAllWithoutPhotos(callback: (error: any, contacts: Contact[]) => void): void; | ||
export function getContactById(contactId: string, callback: (error: any, contact: Contact) => void): void; | ||
export function getPhotoForId(contactId: string, callback: (error: any, photoUri: string) => void): void; | ||
export function addContact(contact: Contact, callback: (error?: any) => void): void; | ||
export function openContactForm(contact: Contact, callback: (error: any, contact: Contact) => void): void; | ||
export function openExistingContact(contact: Contact, callback: (error: any, contact: Contact) => void): void; | ||
export function updateContact(contact: Contact, callback: (error?: any) => void): void; | ||
export function deleteContact(contact: Contact, callback: (error?: any) => void): void; | ||
export function getContactsMatchingString(str: string, callback: (error: any, contacts: Contact[]) => void): void; | ||
export function checkPermission(callback: (error: any, result: 'authorized' | 'denied' | 'undefined') => void): void; | ||
export function requestPermission(callback: (error: any, result: 'authorized' | 'denied' | 'undefined') => void): void; | ||
export function writePhotoToPath(contactId: string, file: string, callback: (error: any, result: boolean) => void): void; | ||
export interface EmailAddress { | ||
label: string; | ||
email: string; | ||
} | ||
export interface EmailAddress { | ||
label: string; | ||
email: string; | ||
} | ||
export interface PhoneNumber { | ||
label: string; | ||
number: string; | ||
} | ||
export interface PhoneNumber { | ||
label: string; | ||
number: string; | ||
} | ||
export interface PostalAddress { | ||
label: string; | ||
formattedAddress: string; | ||
street: string; | ||
pobox: string; | ||
neighborhood: string; | ||
city: string; | ||
region: string; | ||
state: string; | ||
postCode: string; | ||
country: string; | ||
} | ||
export interface PostalAddress { | ||
label: string; | ||
formattedAddress: string; | ||
street: string; | ||
pobox: string; | ||
neighborhood: string; | ||
city: string; | ||
region: string; | ||
state: string; | ||
postCode: string; | ||
country: string; | ||
} | ||
export interface Birthday { | ||
day: number; | ||
month: number; | ||
year: number; | ||
} | ||
export interface Birthday { | ||
day: number; | ||
month: number; | ||
year: number; | ||
} | ||
export interface Contact { | ||
recordID: string; | ||
company: string; | ||
emailAddresses: EmailAddress[]; | ||
familyName: string; | ||
givenName: string; | ||
middleName: string; | ||
jobTitle: string; | ||
phoneNumbers: PhoneNumber[]; | ||
hasThumbnail: boolean; | ||
thumbnailPath: string; | ||
postalAddresses: PostalAddress[]; | ||
prefix: string; | ||
suffix: string; | ||
department: string; | ||
birthday: Birthday; | ||
} | ||
} | ||
export interface Contact { | ||
recordID: string; | ||
company: string; | ||
emailAddresses: EmailAddress[]; | ||
familyName: string; | ||
givenName: string; | ||
middleName: string; | ||
jobTitle: string; | ||
phoneNumbers: PhoneNumber[]; | ||
hasThumbnail: boolean; | ||
thumbnailPath: string; | ||
postalAddresses: PostalAddress[]; | ||
prefix: string; | ||
suffix: string; | ||
department: string; | ||
birthday: Birthday; | ||
} |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "3.1.4", | ||
"version": "3.1.5", | ||
"description": "React Native Contacts (android & ios)", | ||
@@ -10,0 +10,0 @@ "nativePackage": true, |
@@ -46,30 +46,30 @@ # React Native Contacts | ||
### Automatic | ||
with npm | ||
Install with npm or yarn. | ||
With npm | ||
``` | ||
npm install react-native-contacts --save | ||
``` | ||
_the `--save` is necessary for [automatic linking](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#automatic-linking)_ | ||
with yarn | ||
With yarn | ||
``` | ||
yarn add react-native-contacts | ||
``` | ||
and then do | ||
``` | ||
react-native link | ||
``` | ||
If you get an error about | ||
`import Contacts from 'react-native-contacts'; is undefined.` try manual linking below. | ||
and then configure your project. | ||
### Manual | ||
#### iOS | ||
### iOS | ||
1. In XCode, in the project navigator, right click Libraries `Add Files to [your project's name]` | ||
1. add `./node_modules/react-native-contacts/ios/RCTContacts.xcodeproj` | ||
Using the same instructions as https://facebook.github.io/react-native/docs/linking-libraries-ios.html | ||
1. open in xcode `open ios/yourProject.xcodeproj/` | ||
1. drag `./node_modules/react-native-contacts/ios/RCTContacts.xcodeproj` to `Libraries` in you project view. | ||
1. In the XCode project navigator, select your project, | ||
select the `Build Phases` tab and in the `Link Binary With Libraries` section | ||
add `libRCTContacts.a` | ||
select the `Build Phases` tab drag `Libraries > RCTContacts.xcodeproj > Products > libRCTContacts.a` into the `Link Binary With Libraries` section. Video to clarify | ||
[Adding Camera Roll to an ios project in React Native](https://www.youtube.com/watch?v=e3ReNbQu79c). | ||
1. Add kit specific "permission" keys to your Xcode `Info.plist` file, in order to make `requestPermission` work. Otherwise your app crashes when requesting the specific permission. Open `Info.plist`. Add key `Privacy - Contacts Usage Description` with your kit specific permission. The value for the key is optional in development. If you submit to the App Store the value must explain why you need this permission. | ||
#### Android | ||
<img width="338" alt="screen shot 2016-09-21 at 13 13 21" src="https://cloud.githubusercontent.com/assets/5707542/18704973/3cde3b44-7ffd-11e6-918b-63888e33f983.png"> | ||
You should be able to run the app via the Run button in xcode or `react-native run-ios` in the terminal. | ||
### Android | ||
1. In `android/settings.gradle` | ||
@@ -111,22 +111,3 @@ | ||
##### ProGuard | ||
If you use Proguard, the snippet below on proguard-rules.pro | ||
Without it, your apk release version could failed | ||
``` | ||
-keep class com.rt2zz.reactnativecontacts.** {*;} | ||
-keepclassmembers class com.rt2zz.reactnativecontacts.** {*;} | ||
``` | ||
### Permissions | ||
#### iOS | ||
Add kit specific "permission" keys to your Xcode `Info.plist` file, in order to make `requestPermission` work. Otherwise your app crashes when requesting the specific permission. | ||
Open Xcode > open ios/yourApp.xcodeproj > Info.plist > Add key `Privacy - Contacts Usage Description` with your kit specific permission. The value for the key is optional in development. If you submit to the App Store the value must explain why you need this permission. | ||
<img width="338" alt="screen shot 2016-09-21 at 13 13 21" src="https://cloud.githubusercontent.com/assets/5707542/18704973/3cde3b44-7ffd-11e6-918b-63888e33f983.png"> | ||
#### Android | ||
#### Permissions | ||
##### API 23+ | ||
@@ -149,5 +130,16 @@ Android requires allowing permissions with https://facebook.github.io/react-native/docs/permissionsandroid.html | ||
#### ProGuard | ||
If you use Proguard, the snippet below on proguard-rules.pro | ||
Without it, your apk release version could failed | ||
``` | ||
-keep class com.rt2zz.reactnativecontacts.** {*;} | ||
-keepclassmembers class com.rt2zz.reactnativecontacts.** {*;} | ||
``` | ||
## API | ||
* `getAll` (callback) - returns *all* contacts as an array of objects | ||
* `getAllWithoutPhotos` - same as `getAll` on Android, but on iOS it will not return uris for contact photos (because there's a significant overhead in creating the images) | ||
* `getContactById(contactId, callback)` - returns contact with defined contactId (or null if it doesn't exist) | ||
* `getPhotoForId(contactId, callback)` - returns a URI (or null) for a contacts photo | ||
@@ -154,0 +146,0 @@ * `addContact` (contact, callback) - adds a contact to the AddressBook. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
197611
56
341