Since

0.1 This class allows user to add a contact to contact list or to select a contact from list.

Example

import Contacts from '@smartface/native/device/contacts';
import Application from '@smartface/native/application';

const READ_CONTACTS_CODE = 1002;
Application.android.requestPermissions(READ_CONTACTS_CODE, Application.Android.Permissions.READ_CONTACTS);

Application.android.onRequestPermissionsResult = function(e){
if(e.requestCode === READ_CONTACTS_CODE && e.result) {
Contacts.pickContact({
onSuccess: function(e) {
console.log(JSON.stringify(e));
}
}
}

Hierarchy

  • default
    • Contacts

Properties

_nativeObject: any
Contact: ConstructorOf<IContact, Partial<IContact>>

Constructors

  • Parameters

    • Optional params: Record<string, any>

    Returns Contacts

Accessors

  • get nativeObject(): any
  • Returns any

  • set nativeObject(value: any): void
  • Parameters

    • value: any

    Returns void

Methods

  • Executed before constuctor and after createNativeObject. Use this when you have default values which needs to be set before constructor.

    Parameters

    • Optional params: Partial<Record<string, any>>

    Returns void

  • Parameters

    • Optional params: Partial<Record<string, any>>

    Returns void

  • This function adds a contact to contact list with specified properties. You need check Permissions.android#contact before adding contact.

    Example

    import Contacts from '@smartface/native/device/contacts';

    const myContact = new Contacts.Contact({
    firstName: 'Smartface',
    namePrefix: 'Mr.',
    lastName: 'Team',
    urlAddresses: ["https://smartface.io"],
    phoneNumbers: ["+16506173265"],
    emailAddresses: ["info@smartface.io"],
    addresses: ["3790 El Camino Real # 1022 Palo Alto CA, 94306,United States"]
    });
    Contacts.add({
    contact: myContact,
    onSuccess: () => {
    console.log("Success");
    },
    onFailure: () => {
    console.log("Failure");
    }
    });

    Android

    Ios

    Since

    0.1

    Parameters

    • params: { contact: IContact; onSuccess?: (() => void); onFailure?: (() => void) }
      • contact: IContact
      • Optional onSuccess?: (() => void)
          • (): void
          • Returns void

      • Optional onFailure?: (() => void)
          • (): void
          • Returns void

    Returns void

  • This function shows contact list. It allows user to pick a data from the list.You need check Permissions.android#contact before picking contact.

    Example

    import Contacts from '@smartface/native/device/contacts';
    Contacts.pick({
    page : myPage,
    onSuccess : function(contact){
    console.log("Successfully picked");
    },
    onFailure : function(e){
    console.log("Something went wrong");
    }
    });

    Android

    Ios

    Since

    0.1

    Parameters

    • page: IPage<"load" | "dismissComplete" | "dismissStart" | "dismissCancel" | "hide" | "show" | "orientationChange" | "safeAreaPaddingChange", MobileOSProps<PageIOSParams, PageAndroidParams>, any>
    • handlers: { onSuccess: ((contact: IContact) => void); onFailure?: (() => void) }
      • onSuccess: ((contact: IContact) => void)
      • Optional onFailure?: (() => void)
          • (): void
          • Returns void

    Returns void

  • This function returns a contact array.You need check Permissions.android#contact before using this function.

    Example

    import Contacts from '@smartface/native/device/contacts';
    Contacts.fetchAll({
    onSuccess : function(contacts){
    var count = contacts.length;
    },
    onFailure : function(error){
    console.log("Message : " + error);
    }
    });

    Method

    getAll

    Android

    Ios

    Since

    0.1

    Parameters

    • handlers: { onSuccess: ((contacts: IContact[]) => void); onFailure?: ((error: string) => void) }
      • onSuccess: ((contacts: IContact[]) => void)
      • Optional onFailure?: ((error: string) => void)
          • (error: string): void
          • Parameters

            • error: string

            Returns void

    Returns void

  • This function searches contacts by given phone number.You need check Permissions.android#contact permission.

    Example

    import Contacts from '@smartface/native/device/contacts';
    Contacts.getContactsByPhoneNumber("5555555555",{
    onSuccess : function(contacts){
    console.log("Successfully found ", contacts);
    },
    onFailure : function(error){
    console.log("Something went wrong");
    }
    });

    Android

    Ios

    Since

    4.3.0

    Parameters

    • phoneNumber: string
    • handlers: { onSuccess: ((contacts: IContact[]) => void); onFailure?: ((error: string) => void) }
      • onSuccess: ((contacts: IContact[]) => void)
      • Optional onFailure?: ((error: string) => void)
          • (error: string): void
          • Parameters

            • error: string

            Returns void

    Returns void

Generated using TypeDoc