Skip to content

contacts

const contacts: {
get: Promise<UserContact>;
getPage: Promise<Page<UserContact>>;
eachPage: Promise<void>;
};

Defined in: domains/contacts.ts:10

get(contactID): Promise<UserContact>;

Get a specific contact by ID.

Parameter Type Description
contactID number The ID of the contact to fetch.

Promise<UserContact>

A UserContact object.

MobileLockerError on network failure or server error.

getPage(limit, cursor?): Promise<Page<UserContact>>;

Get one page of contacts (cursor envelope).

Requires Mobile Locker iOS 5.5.0+. Prefer contacts.eachPage when walking the whole book. Production users can have 100k+ contacts (MLJS-24 / MLJS-27); do not reassemble every page into one array.

Host: GET /mobilelocker/api/user-contacts?limit=&cursor={ data, meta: { cursor: { next, count } } } (MLI-1718).

Parameter Type Description
limit number Page size (1…5000).
cursor? string From previous meta.cursor.next. Omit for the first page.

Promise<Page<UserContact>>

Page of UserContact records.

MobileLockerError with code InvalidArgument when limit is out of range.

MobileLockerError on network failure or server error.

const page = await mobilelocker.contacts.getPage(500)
const next = page.meta.cursor.next
? await mobilelocker.contacts.getPage(500, page.meta.cursor.next)
: null
eachPage(pageSize, handler): Promise<void>;

Walk the address book page by page without loading everything into memory.

Replaces the removed getAll() (MLJS-24) and intermediate getChunked(min, limit) (MLJS-27). Advances only via meta.cursor.next; stops when next === null. Process each chunk in handler. Do not push chunks into a growing array unless the book is known to be small. Requires iOS 5.5.0+.

Parameter Type Description
pageSize number Page size passed to contacts.getPage (1…5000).
handler (chunk) => void | Promise<void> Called once per non-empty page; may be async.

Promise<void>

MobileLockerError when pageSize is out of range, or on network/server error.

await mobilelocker.contacts.eachPage(500, (chunk) => {
for (const contact of chunk) {
// handle one contact — never accumulate the full book
}
})