Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add react-native-contacts type definitions for v5.x.x #4045

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,132 @@
declare module 'react-native-contacts' {
declare interface EmailAddress {
label: string;
email: string;
}

declare interface PhoneNumber {
label: string;
number: string;
}

declare interface PostalAddress {
label: string;
formattedAddress: string;
street: string;
pobox: string;
neighborhood: string;
city: string;
region: string;
state: string;
postCode: string;
country: string;
}

declare interface InstantMessageAddress {
username: string;
service: string;
}

declare interface Birthday {
day: number;
month: number;
year: number;
}

declare interface Contact {
recordID: string;
backTitle: 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;
imAddresses: InstantMessageAddress[];
note: string;
}

declare export function getAll(
callback: (error: mixed, contacts: Contact[]) => void
): void;

declare export function getAllWithoutPhotos(
callback: (error: mixed, contacts: Contact[]) => void
): void;

declare export function getContactById(
contactId: string,
callback: (error: mixed, contact: Contact) => void
): void;

declare export function getCount(callback: (count: number) => void): void;

declare export function getPhotoForId(
contactId: string,
callback: (error: mixed, photoUri: string) => void
): void;

declare export function addContact(
contact: Contact,
callback: (error?: mixed) => void
): void;

declare export function openContactForm(
contact: $Rest<Contact, { ... }>,
callback: (error: mixed, contact: Contact) => void
): void;

declare export function openExistingContact(
contact: Contact,
callback: (error: mixed, contact: Contact) => void
): void;

declare export function editExistingContact(
contact: Contact,
callback: (error: mixed, contact: Contact) => void
): void;

declare export function updateContact(
contact: Contact,
callback: (error?: mixed) => void
): void;

declare export function deleteContact(
contact: Contact,
callback: (error?: mixed) => void
): void;

declare export function getContactsMatchingString(
str: string,
callback: (error: mixed, contacts: Contact[]) => void
): void;

declare export function getContactsByPhoneNumber(
phoneNumber: string,
callback: (error: mixed, contacts: Contact[]) => void
): void;

declare export function checkPermission(
callback: (error: mixed, result: "authorized" | "denied" | "undefined") => void
): void;

declare export function requestPermission(
callback: (error: mixed, result: "authorized" | "denied" | "undefined") => void
): void;

declare export function writePhotoToPath(
contactId: string,
file: string,
callback: (error: mixed, result: boolean) => void
): void;

declare export function iosEnableNotesUsage(enabled: boolean): void;
}