Contacts
Read the current user’s contacts (address book). Production books can exceed 100k rows — always walk with cursor paging. Process one page at a time; do not rebuild the full book in memory.
Public surface (contacts): get · getPage · eachPage
Requires Mobile Locker iOS 5.5.0+ for list walks. There is no getAll() and no getChunked(min, limit) (removed in SDK 2.0). Failures throw MobileLockerError.
Fetch one contact
Section titled “Fetch one contact”get(contactID: number): Promise<UserContact>import mobilelocker from '@mobilelocker/javascript-sdk'
const contact = await mobilelocker.contacts.get(contactID)contactID is a number (user address-book id — not a Salesforce CRM id).
Walk page by page (preferred)
Section titled “Walk page by page (preferred)”eachPage( pageSize: number, handler: (chunk: UserContact[]) => void | Promise<void>,): Promise<void>Host envelope:
GET …/user-contacts?limit=1…5000&cursor=→ { data, meta: { cursor: { next, count } } }await mobilelocker.contacts.eachPage(500, (chunk) => { for (const c of chunk) { // render / index / filter this contact only }})Single page
Section titled “Single page”getPage(limit: number, cursor?: string): Promise<Page<UserContact>>// Page<T>: { data: T[]; meta: { cursor: { next: string | null; count: number } } }const page = await mobilelocker.contacts.getPage(500)// page.data — UserContact[]// page.meta.cursor.next — string | null// page.meta.cursor.count — number (rows in this page)
if (page.meta.cursor.next) { const next = await mobilelocker.contacts.getPage(500, page.meta.cursor.next)}limit / pageSize must be an integer 1…5000 or the SDK throws InvalidArgument (GeneralErrorCode.InvalidArgument).
Related
Section titled “Related”- CRM — CRM contacts are a different domain (
crm.getContact/ SOQL; IDs are strings) - Scanner — capture new leads on device
- Search — cross-entity search including contacts
- Errors
API reference
Section titled “API reference”- Module:
contacts - Types:
UserContact,Page,PageCursor