Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save marchbold/42838c3e467200a28918 to your computer and use it in GitHub Desktop.

Select an option

Save marchbold/42838c3e467200a28918 to your computer and use it in GitHub Desktop.
Display a native picker dialog for user contact selection
// Before here we have already requested access and performed the initialisation (as above)
Contacts.service.addEventListener( ContactsEvent.CONTACT_SELECTED, contact_selectedHandler );
Contacts.service.addEventListener( ContactsEvent.CONTACTPICKER_CANCEL, contacts_contactPickerCancelHandler );
if (!Contacts.service.showContactPicker())
{
trace( "Access to contacts list denied by user" );
}
...
private function contact_selectedHandler( event:ContactsEvent ):void
{
if (event.data)
{
var contact:Contact = event.data[0];
trace("Name: " + contact.fullName);
trace("Org: " + contact.organisation.name + " -- " + contact.organisation.title);
for each (var e:Object in contact.emailAddresses)
{
trace(e.label + " -- " + e.value);
}
}
}
private function contacts_contactPickerCancelHandler( event:ContactsEvent ):void
{
trace( "Picker cancelled" );
}
// com.distriqt.Contacts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment