{"id":4589,"url":"https://github.com/rt2zz/react-native-addressbook","last_synced_at":"2025-05-07T06:50:47.875Z","repository":{"id":31088441,"uuid":"34647510","full_name":"rt2zz/react-native-addressbook","owner":"rt2zz","description":"React Native AddressBook","archived":false,"fork":false,"pushed_at":"2017-04-16T23:25:09.000Z","size":59,"stargazers_count":82,"open_issues_count":6,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-01T13:52:49.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rt2zz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-27T05:20:29.000Z","updated_at":"2022-08-09T06:50:38.000Z","dependencies_parsed_at":"2022-08-03T06:45:56.928Z","dependency_job_id":null,"html_url":"https://github.com/rt2zz/react-native-addressbook","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rt2zz%2Freact-native-addressbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rt2zz%2Freact-native-addressbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rt2zz%2Freact-native-addressbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rt2zz%2Freact-native-addressbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rt2zz","download_url":"https://codeload.github.com/rt2zz/react-native-addressbook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831181,"owners_count":21810780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:17.233Z","updated_at":"2025-05-07T06:50:47.854Z","avatar_url":"https://github.com/rt2zz.png","language":"Objective-C","funding_links":[],"categories":["Components"],"sub_categories":["System"],"readme":"# React Native AddressBook\n**NOTE** Future development will occur at [react-native-contacts](https://github.com/rt2zz/react-native-contacts). Migration is trivial (rename `getContacts` -\u003e `getAll`)\n\n## API\n`getContacts` (callback) - returns *all* contacts as an array of objects  \n`addContact` (contact, callback) - adds a contact to the AddressBook.  \n`updateContact` (contact, callback) - where contact is an object with a valid recordID  \n`deleteContact` (contact, callback) - where contact is an object with a valid recordID  \n\n####Permissions Methods (optional)\n`checkPermission` (callback) - checks permission to use AddressBook.  \n`requestPermission` (callback) - request permission to use AddressBook.  \n\n## Usage Example\n```js\nvar AddressBook = require('react-native-addressbook')\n\nAddressBook.getContacts( (err, contacts) =\u003e {\n  if(err \u0026\u0026 err.type === 'permissionDenied'){\n    // x.x\n  }\n  else{\n    console.log(contacts)\n  }\n})\n```\n\n## Example Contact Record\n```js\n{\n  recordID: 1,\n  lastName: \"Jung\",\n  firstName: \"Carl\",\n  middleName: \"\",\n  emailAddresses: [{\n    label: \"work\",\n    email: \"carl-jung@example.com\",\n  }],\n  phoneNumbers: [{\n    label: \"mobile\",\n    number: \"(555) 555-5555\",\n  }],\n  thumbnailPath: \"\",\n}\n```\n\n## Adding Contacts\nCurrently all fields from the contact record except for thumbnailPath are supported for writing\n```js\nvar newPerson = {\n  lastName: \"Nietzsche\",\n  firstName: \"Friedrich\",\n  emailAddresses: [{\n    label: \"work\",\n    email: \"mrniet@example.com\",\n  }],\n}\n\nAddressBook.addContact(newPerson, (err) =\u003e { /*...*/ })\n```\n\n## Updating and Deleting Contacts\n```js\n//contrived example\nAddressBook.getContacts( (err, contacts) =\u003e {\n  //update the first record\n  let someRecord = contacts[0]\n  someRecord.emailAddresses.push({\n    label: \"junk\",\n    email: \"mrniet+junkmail@test.com\",\n  })\n  AddressBook.updateContact(someRecord, (err) =\u003e { /*...*/ })\n\n  //delete the second record\n  AddressBook.deleteContact(contacts[1], (err) =\u003e { /*...*/ })\n})\n```\nUpdate and delete reference contacts by their recordID (as returned by the OS in getContacts). Apple does not guarantee the recordID will not change, e.g. it may be reassigned during a phone migration. Consequently you should always grab a fresh contact list with `getContacts` before performing update and delete operations.\n\nYou can also delete a record using only it's recordID like follows: `AddressBook.deleteContact({recordID: 1}, (err) =\u003e {})}`\n\n##Permissions\nPermissions will automatically be checked and if needed requested upon calling getContacts. If you need more granular control you can using the checkPermission and requestPermission methods as follows:\n```js\nAddressBook.checkPermission( (err, permission) =\u003e {\n  // AddressBook.PERMISSION_AUTHORIZED || AddressBook.PERMISSION_UNDEFINED || AddressBook.PERMISSION_DENIED\n  if(permission === 'undefined'){\n    AddressBook.requestPermission( (err, permission) =\u003e {\n      // ...\n    })\n  }\n  if(permission === 'authorized'){\n    // yay!\n  }\n  if(permission === 'denied'){\n    // x.x\n  }\n})\n```\n\n## Getting started\n1. `npm install react-native-addressbook`\n2. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`\n3. add `./node_modules/react-native-addressbook/RCTAddressBook.xcodeproj`\n4. In the XCode project navigator, select your project, select the `Build Phases` tab and in the `Link Binary With Libraries` section add **libRCTAddressBook.a**\n\n## Todo\n- [x] `checkPermission` \u0026 `requestPermission`\n- [x] `getContacts` (get all contacts)\n- [x] `addContact`\n- [x] Update and Delete methods\n- [ ] `getContacts` options (a la camera roll's getPhotos)\n- [x] Automatic permission check \u0026 request in `getContacts`\n- [ ] Contact Groups support\n\n## Credits\nThanks to @mattotodd whose [RCTAddressBook](https://github.com/mattotodd/react-native-addressbook-ios) this is largely derived from.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frt2zz%2Freact-native-addressbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frt2zz%2Freact-native-addressbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frt2zz%2Freact-native-addressbook/lists"}