Skip to content

CNContactPickerContactEvent ​

CNContactPickerContactEvent represents the user tapping a contact in the system contact picker.

The contactselect event of CNContactPickerViewController is this class, and contact is the contact chosen.

It belongs to the @nacrejs/contacts package; for installation, see CNContactPickerViewController.

Inheritance: Event → CNContactPickerContactEvent

Constructor ​

CNContactPickerContactEvent()

Creates a CNContactPickerContactEvent. The runtime creates one itself when it fires the events below; app code can use it to build an event object and fire it with dispatchEvent() to try out a listener.

Instance properties ​

Also inherits the properties of Event; the most commonly used are type and target. The properties below are read-only; assigning to them throws TypeError.

PropertyDescription
contact read-onlyThe contact the user chose

These properties live on the prototype, not on the event object itself: Object.keys(event) and { ...event } don't include them, so read them one by one. See Events with fields.

Events that use this class ​

ObjectEvents
CNContactPickerViewControllercontactselect

It can't be canceled: cancelable is false, and preventDefault() has no effect. After it is fired, the system closes the picker.

Examples ​

js
const page = new UIViewController();
const picker = new CNContactPickerViewController();
picker.addEventListener('contactselect', (e) => {
  console.log(e instanceof CNContactPickerContactEvent);
});
page.presentViewController(picker, { animated: true });

Effect: after the user makes a choice in the picker, prints true. Not verified in the simulator.

Corresponding iOS API ​

ObjCJS
contactPicker:didSelectContact:The contactselect event
The contact parameterevent.contact

See also ​