Device.getContacts
函数式 API
fetchContacts也可以通过它使用相同的功能。
功能说明
按页获取用户的联系人列表。 size·offset进行分页, query.contains可进行名称包含搜索。 offset在首次调用时 0,之后使用响应中的 nextOffset。
如果没有读取联系人权限 FetchContactsPermissionError会发生。 Device.getContacts.getPermission() / Device.getContacts.openPermissionDialog()可以用来确认并请求权限。
类型
Device.getContacts(options: FetchContactsOptions): Promise<ContactResult>;Params
type FetchContactsOptions = {
size: number;
offset: number;
query?: {
contains?: string;
};
};Response
type ContactEntity = {
name: string;
phoneNumber: string;
};
type ContactResult = {
result: ContactEntity[];
nextOffset: number | null;
done: boolean;
};错误
错误会以类的形式抛出 — error instanceof FetchContactsPermissionError来识别。该类可在 @apps-in-toss/web-framework中导入。
错误类
说明
FetchContactsPermissionError
表示读取联系人权限被拒绝的情况。 Device.getContacts.openPermissionDialog()可以重新请求。
示例代码
这有帮助吗?