@capacitor/contacts 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorContacts.podspec +18 -0
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/Package.swift +28 -0
- package/README.md +357 -0
- package/android/build.gradle +88 -0
- package/android/src/main/AndroidManifest.xml +7 -0
- package/android/src/main/kotlin/com/capacitorjs/plugins/contacts/Contacts.kt +924 -0
- package/android/src/main/kotlin/com/capacitorjs/plugins/contacts/ContactsError.kt +27 -0
- package/android/src/main/kotlin/com/capacitorjs/plugins/contacts/ContactsPlugin.kt +278 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +948 -0
- package/dist/esm/definitions.d.ts +440 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +14 -0
- package/dist/esm/web.js +22 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +36 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +39 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/ContactsPlugin/Contacts.swift +257 -0
- package/ios/Sources/ContactsPlugin/ContactsError.swift +43 -0
- package/ios/Sources/ContactsPlugin/ContactsMapping.swift +310 -0
- package/ios/Sources/ContactsPlugin/ContactsPlugin.swift +166 -0
- package/ios/Tests/ContactsPluginTests/ContactsTests.swift +69 -0
- package/package.json +92 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
export interface ContactsPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Queries the device contacts database and returns the matching contacts.
|
|
4
|
+
*
|
|
5
|
+
* Requests the READ_CONTACTS (Android) / Contacts (iOS) permission internally
|
|
6
|
+
* the first time it runs; there is no separate permission method.
|
|
7
|
+
*
|
|
8
|
+
* **iOS 18+:** under Limited Access the search runs against (and returns
|
|
9
|
+
* only) the subset of contacts the user shared with the app.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
find(options: ContactFindOptions): Promise<ContactFindResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Persists a new contact or updates an existing one (matched by `contact.id`).
|
|
16
|
+
* Resolves with the full saved contact.
|
|
17
|
+
*
|
|
18
|
+
* Requests the READ/WRITE_CONTACTS (Android) / Contacts (iOS) permission
|
|
19
|
+
* internally.
|
|
20
|
+
*
|
|
21
|
+
* **iOS 18+:** works under Limited Access: new contacts are added to the
|
|
22
|
+
* app's accessible set; updating requires the target contact to be in that
|
|
23
|
+
* set (otherwise the call rejects with `OS-PLUG-CONT-0001`).
|
|
24
|
+
*
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
*/
|
|
27
|
+
save(options: ContactSaveOptions): Promise<Contact>;
|
|
28
|
+
/**
|
|
29
|
+
* Removes the contact with the given `id` from the device contacts database.
|
|
30
|
+
* Rejects with `OS-PLUG-CONT-0001` when no contact has that id (on iOS 18+
|
|
31
|
+
* Limited Access, also when the contact is outside the accessible set).
|
|
32
|
+
*
|
|
33
|
+
* Requests the READ/WRITE_CONTACTS (Android) / Contacts (iOS) permission
|
|
34
|
+
* internally.
|
|
35
|
+
*
|
|
36
|
+
* @since 1.0.0
|
|
37
|
+
*/
|
|
38
|
+
remove(options: ContactRemoveOptions): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Launches the native contact picker UI and resolves with the contact the
|
|
41
|
+
* user selects. Rejects with `OS-PLUG-CONT-0006` if the user cancels.
|
|
42
|
+
*
|
|
43
|
+
* On iOS the system picker requires no permission and always shows the full
|
|
44
|
+
* contact list, even under iOS 18+ Limited Access (the picked contact is
|
|
45
|
+
* returned without joining the app's accessible set). On Android the
|
|
46
|
+
* READ_CONTACTS permission is requested internally to read the picked
|
|
47
|
+
* contact's details.
|
|
48
|
+
*
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
*/
|
|
51
|
+
pickContact(): Promise<Contact>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The set of contact fields a {@link ContactsPlugin.find} call can search
|
|
55
|
+
* against or request back. Mirrors the legacy Cordova `ContactFieldType`
|
|
56
|
+
* string values exactly.
|
|
57
|
+
*
|
|
58
|
+
* @since 1.0.0
|
|
59
|
+
*/
|
|
60
|
+
export type ContactFieldType = 'addresses' | 'birthday' | 'categories' | 'country' | 'department' | 'displayName' | 'emails' | 'familyName' | 'formatted' | 'givenName' | 'honorificPrefix' | 'honorificSuffix' | 'id' | 'ims' | 'locality' | 'middleName' | 'name' | 'nickname' | 'note' | 'organizations' | 'phoneNumbers' | 'photos' | 'postalCode' | 'region' | 'streetAddress' | 'title' | 'urls';
|
|
61
|
+
/**
|
|
62
|
+
* Search options accepted by {@link ContactsPlugin.find}.
|
|
63
|
+
*
|
|
64
|
+
* @since 1.0.0
|
|
65
|
+
*/
|
|
66
|
+
export interface ContactFindOptions {
|
|
67
|
+
/**
|
|
68
|
+
* Fields to search against. Pass `['*']` to match every field. An empty
|
|
69
|
+
* array is invalid and rejects with `OS-PLUG-CONT-0001`. The `id` field
|
|
70
|
+
* matches by exact identifier; all other fields match case-insensitive
|
|
71
|
+
* substrings. `photos` and `categories` are not searchable.
|
|
72
|
+
*
|
|
73
|
+
* @since 1.0.0
|
|
74
|
+
*/
|
|
75
|
+
fields: ContactFieldType[];
|
|
76
|
+
/**
|
|
77
|
+
* Search string matched (case-insensitively) against the selected `fields`.
|
|
78
|
+
* An empty/omitted filter returns every contact.
|
|
79
|
+
*
|
|
80
|
+
* @since 1.0.0
|
|
81
|
+
*/
|
|
82
|
+
filter?: string;
|
|
83
|
+
/**
|
|
84
|
+
* When `true`, returns every match; when `false` (default), returns at most
|
|
85
|
+
* one contact.
|
|
86
|
+
*
|
|
87
|
+
* @since 1.0.0
|
|
88
|
+
*/
|
|
89
|
+
multiple?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* If set, each returned {@link Contact} only includes these fields (plus the
|
|
92
|
+
* always-present `id`).
|
|
93
|
+
*
|
|
94
|
+
* @since 1.0.0
|
|
95
|
+
*/
|
|
96
|
+
desiredFields?: ContactFieldType[];
|
|
97
|
+
/**
|
|
98
|
+
* OutSystems extension: when `true`, only contacts that have at least one
|
|
99
|
+
* phone number are returned. Defaults to `false`.
|
|
100
|
+
*
|
|
101
|
+
* @since 1.0.0
|
|
102
|
+
*/
|
|
103
|
+
hasPhoneNumber?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Result of a {@link ContactsPlugin.find} call.
|
|
107
|
+
*
|
|
108
|
+
* @since 1.0.0
|
|
109
|
+
*/
|
|
110
|
+
export interface ContactFindResult {
|
|
111
|
+
/**
|
|
112
|
+
* The contacts matching the search criteria.
|
|
113
|
+
*
|
|
114
|
+
* @since 1.0.0
|
|
115
|
+
*/
|
|
116
|
+
contacts: Contact[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Options accepted by {@link ContactsPlugin.save}.
|
|
120
|
+
*
|
|
121
|
+
* @since 1.0.0
|
|
122
|
+
*/
|
|
123
|
+
export interface ContactSaveOptions {
|
|
124
|
+
/**
|
|
125
|
+
* The contact to create (no `id`) or update (existing `id`).
|
|
126
|
+
*
|
|
127
|
+
* Update semantics: every field present on the contact replaces the stored
|
|
128
|
+
* value entirely (e.g. `name` replaces the whole structured name,
|
|
129
|
+
* `phoneNumbers` replaces all phone numbers); omitted fields are left
|
|
130
|
+
* unchanged.
|
|
131
|
+
*
|
|
132
|
+
* @since 1.0.0
|
|
133
|
+
*/
|
|
134
|
+
contact: Contact;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Options accepted by {@link ContactsPlugin.remove}.
|
|
138
|
+
*
|
|
139
|
+
* @since 1.0.0
|
|
140
|
+
*/
|
|
141
|
+
export interface ContactRemoveOptions {
|
|
142
|
+
/**
|
|
143
|
+
* The native id of the contact to remove.
|
|
144
|
+
*
|
|
145
|
+
* @since 1.0.0
|
|
146
|
+
*/
|
|
147
|
+
id: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* A single device contact.
|
|
151
|
+
*
|
|
152
|
+
* @since 1.0.0
|
|
153
|
+
*/
|
|
154
|
+
export interface Contact {
|
|
155
|
+
/**
|
|
156
|
+
* Globally unique, platform-assigned identifier. Absent for contacts not yet
|
|
157
|
+
* saved to the device.
|
|
158
|
+
*
|
|
159
|
+
* @since 1.0.0
|
|
160
|
+
*/
|
|
161
|
+
id?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Android raw-contact id backing this aggregated contact. iOS leaves this
|
|
164
|
+
* unset.
|
|
165
|
+
*
|
|
166
|
+
* @since 1.0.0
|
|
167
|
+
*/
|
|
168
|
+
rawId?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Name suitable for display to end users.
|
|
171
|
+
*
|
|
172
|
+
* @since 1.0.0
|
|
173
|
+
*/
|
|
174
|
+
displayName?: string;
|
|
175
|
+
/**
|
|
176
|
+
* The structured name components.
|
|
177
|
+
*
|
|
178
|
+
* @since 1.0.0
|
|
179
|
+
*/
|
|
180
|
+
name?: ContactName;
|
|
181
|
+
/**
|
|
182
|
+
* A casual name by which to address the contact.
|
|
183
|
+
*
|
|
184
|
+
* @since 1.0.0
|
|
185
|
+
*/
|
|
186
|
+
nickname?: string;
|
|
187
|
+
/**
|
|
188
|
+
* The contact's phone numbers.
|
|
189
|
+
*
|
|
190
|
+
* @since 1.0.0
|
|
191
|
+
*/
|
|
192
|
+
phoneNumbers?: ContactField[];
|
|
193
|
+
/**
|
|
194
|
+
* The contact's email addresses.
|
|
195
|
+
*
|
|
196
|
+
* @since 1.0.0
|
|
197
|
+
*/
|
|
198
|
+
emails?: ContactField[];
|
|
199
|
+
/**
|
|
200
|
+
* The contact's postal addresses.
|
|
201
|
+
*
|
|
202
|
+
* @since 1.0.0
|
|
203
|
+
*/
|
|
204
|
+
addresses?: ContactAddress[];
|
|
205
|
+
/**
|
|
206
|
+
* The contact's instant-messaging handles.
|
|
207
|
+
*
|
|
208
|
+
* @since 1.0.0
|
|
209
|
+
*/
|
|
210
|
+
ims?: ContactField[];
|
|
211
|
+
/**
|
|
212
|
+
* The contact's organizations.
|
|
213
|
+
*
|
|
214
|
+
* @since 1.0.0
|
|
215
|
+
*/
|
|
216
|
+
organizations?: ContactOrganization[];
|
|
217
|
+
/**
|
|
218
|
+
* The contact's birthday as epoch milliseconds.
|
|
219
|
+
*
|
|
220
|
+
* @since 1.0.0
|
|
221
|
+
*/
|
|
222
|
+
birthday?: number;
|
|
223
|
+
/**
|
|
224
|
+
* A free-form note about the contact.
|
|
225
|
+
*
|
|
226
|
+
* **iOS:** not supported by default: reading/writing a contact's note
|
|
227
|
+
* requires Apple's restricted `com.apple.developer.contacts.notes`
|
|
228
|
+
* entitlement. Without it the field is omitted on read and ignored on save.
|
|
229
|
+
* Android has no such restriction.
|
|
230
|
+
*
|
|
231
|
+
* @since 1.0.0
|
|
232
|
+
*/
|
|
233
|
+
note?: string;
|
|
234
|
+
/**
|
|
235
|
+
* The contact's photos. Reads return `type: 'url'` with the `value`
|
|
236
|
+
* holding a reference to the image, never image bytes: on Android the
|
|
237
|
+
* contact's `content://` photo URI, on iOS the path of a copy written to
|
|
238
|
+
* the app's temporary directory (cleared by the system). On save, the first entry is
|
|
239
|
+
* applied: pass `type: 'base64'` with base64 data, or `type: 'url'` with a
|
|
240
|
+
* local `file://`/`content://` URI to import.
|
|
241
|
+
*
|
|
242
|
+
* @since 1.0.0
|
|
243
|
+
*/
|
|
244
|
+
photos?: ContactField[];
|
|
245
|
+
/**
|
|
246
|
+
* User-defined categories associated with the contact. Read-only: populated
|
|
247
|
+
* from the contact's group memberships on Android, never returned on iOS
|
|
248
|
+
* (the Contacts framework has no equivalent), and ignored on save.
|
|
249
|
+
*
|
|
250
|
+
* @since 1.0.0
|
|
251
|
+
*/
|
|
252
|
+
categories?: ContactField[];
|
|
253
|
+
/**
|
|
254
|
+
* Web pages associated with the contact.
|
|
255
|
+
*
|
|
256
|
+
* @since 1.0.0
|
|
257
|
+
*/
|
|
258
|
+
urls?: ContactField[];
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Structured name of a {@link Contact}.
|
|
262
|
+
*
|
|
263
|
+
* @since 1.0.0
|
|
264
|
+
*/
|
|
265
|
+
export interface ContactName {
|
|
266
|
+
/**
|
|
267
|
+
* The complete formatted name.
|
|
268
|
+
*
|
|
269
|
+
* @since 1.0.0
|
|
270
|
+
*/
|
|
271
|
+
formatted?: string;
|
|
272
|
+
/**
|
|
273
|
+
* Family (last) name.
|
|
274
|
+
*
|
|
275
|
+
* @since 1.0.0
|
|
276
|
+
*/
|
|
277
|
+
familyName?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Given (first) name.
|
|
280
|
+
*
|
|
281
|
+
* @since 1.0.0
|
|
282
|
+
*/
|
|
283
|
+
givenName?: string;
|
|
284
|
+
/**
|
|
285
|
+
* Middle name.
|
|
286
|
+
*
|
|
287
|
+
* @since 1.0.0
|
|
288
|
+
*/
|
|
289
|
+
middleName?: string;
|
|
290
|
+
/**
|
|
291
|
+
* Honorific prefix (e.g. `Mr.`, `Dr.`).
|
|
292
|
+
*
|
|
293
|
+
* @since 1.0.0
|
|
294
|
+
*/
|
|
295
|
+
honorificPrefix?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Honorific suffix (e.g. `Esq.`).
|
|
298
|
+
*
|
|
299
|
+
* @since 1.0.0
|
|
300
|
+
*/
|
|
301
|
+
honorificSuffix?: string;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* A generic, repeatable contact field (phone number, email, IM, photo, URL,
|
|
305
|
+
* category).
|
|
306
|
+
*
|
|
307
|
+
* @since 1.0.0
|
|
308
|
+
*/
|
|
309
|
+
export interface ContactField {
|
|
310
|
+
/**
|
|
311
|
+
* The kind of field, e.g. `home`, `work`, `mobile`. For photos, `url` or
|
|
312
|
+
* `base64`.
|
|
313
|
+
*
|
|
314
|
+
* @since 1.0.0
|
|
315
|
+
*/
|
|
316
|
+
type?: string;
|
|
317
|
+
/**
|
|
318
|
+
* The field value (phone number, email address, URI, etc.).
|
|
319
|
+
*
|
|
320
|
+
* @since 1.0.0
|
|
321
|
+
*/
|
|
322
|
+
value?: string;
|
|
323
|
+
/**
|
|
324
|
+
* `true` if this is the contact's preferred value for the field.
|
|
325
|
+
*
|
|
326
|
+
* @since 1.0.0
|
|
327
|
+
*/
|
|
328
|
+
pref?: boolean;
|
|
329
|
+
/**
|
|
330
|
+
* Platform-assigned id of this individual field entry.
|
|
331
|
+
*
|
|
332
|
+
* @since 1.0.0
|
|
333
|
+
*/
|
|
334
|
+
id?: string;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* A postal address of a {@link Contact}.
|
|
338
|
+
*
|
|
339
|
+
* @since 1.0.0
|
|
340
|
+
*/
|
|
341
|
+
export interface ContactAddress {
|
|
342
|
+
/**
|
|
343
|
+
* Platform-assigned id of this address entry.
|
|
344
|
+
*
|
|
345
|
+
* @since 1.0.0
|
|
346
|
+
*/
|
|
347
|
+
id?: string;
|
|
348
|
+
/**
|
|
349
|
+
* `true` if this is the contact's preferred address.
|
|
350
|
+
*
|
|
351
|
+
* @since 1.0.0
|
|
352
|
+
*/
|
|
353
|
+
pref?: boolean;
|
|
354
|
+
/**
|
|
355
|
+
* The kind of address, e.g. `home`, `work`.
|
|
356
|
+
*
|
|
357
|
+
* @since 1.0.0
|
|
358
|
+
*/
|
|
359
|
+
type?: string;
|
|
360
|
+
/**
|
|
361
|
+
* The full address formatted for display.
|
|
362
|
+
*
|
|
363
|
+
* @since 1.0.0
|
|
364
|
+
*/
|
|
365
|
+
formatted?: string;
|
|
366
|
+
/**
|
|
367
|
+
* The street address.
|
|
368
|
+
*
|
|
369
|
+
* @since 1.0.0
|
|
370
|
+
*/
|
|
371
|
+
streetAddress?: string;
|
|
372
|
+
/**
|
|
373
|
+
* The city or locality.
|
|
374
|
+
*
|
|
375
|
+
* @since 1.0.0
|
|
376
|
+
*/
|
|
377
|
+
locality?: string;
|
|
378
|
+
/**
|
|
379
|
+
* The state or region.
|
|
380
|
+
*
|
|
381
|
+
* @since 1.0.0
|
|
382
|
+
*/
|
|
383
|
+
region?: string;
|
|
384
|
+
/**
|
|
385
|
+
* The ZIP or postal code.
|
|
386
|
+
*
|
|
387
|
+
* @since 1.0.0
|
|
388
|
+
*/
|
|
389
|
+
postalCode?: string;
|
|
390
|
+
/**
|
|
391
|
+
* The country name.
|
|
392
|
+
*
|
|
393
|
+
* @since 1.0.0
|
|
394
|
+
*/
|
|
395
|
+
country?: string;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* An organization a {@link Contact} belongs to.
|
|
399
|
+
*
|
|
400
|
+
* @since 1.0.0
|
|
401
|
+
*/
|
|
402
|
+
export interface ContactOrganization {
|
|
403
|
+
/**
|
|
404
|
+
* Platform-assigned id of this organization entry. Android only; iOS
|
|
405
|
+
* models the organization as flat contact properties without an id.
|
|
406
|
+
*
|
|
407
|
+
* @since 1.0.0
|
|
408
|
+
*/
|
|
409
|
+
id?: string;
|
|
410
|
+
/**
|
|
411
|
+
* `true` if this is the contact's preferred organization.
|
|
412
|
+
*
|
|
413
|
+
* @since 1.0.0
|
|
414
|
+
*/
|
|
415
|
+
pref?: boolean;
|
|
416
|
+
/**
|
|
417
|
+
* The kind of organization, e.g. `work`.
|
|
418
|
+
*
|
|
419
|
+
* @since 1.0.0
|
|
420
|
+
*/
|
|
421
|
+
type?: string;
|
|
422
|
+
/**
|
|
423
|
+
* The organization name.
|
|
424
|
+
*
|
|
425
|
+
* @since 1.0.0
|
|
426
|
+
*/
|
|
427
|
+
name?: string;
|
|
428
|
+
/**
|
|
429
|
+
* The department within the organization.
|
|
430
|
+
*
|
|
431
|
+
* @since 1.0.0
|
|
432
|
+
*/
|
|
433
|
+
department?: string;
|
|
434
|
+
/**
|
|
435
|
+
* The contact's title at the organization.
|
|
436
|
+
*
|
|
437
|
+
* @since 1.0.0
|
|
438
|
+
*/
|
|
439
|
+
title?: string;
|
|
440
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface ContactsPlugin {\n /**\n * Queries the device contacts database and returns the matching contacts.\n *\n * Requests the READ_CONTACTS (Android) / Contacts (iOS) permission internally\n * the first time it runs; there is no separate permission method.\n *\n * **iOS 18+:** under Limited Access the search runs against (and returns\n * only) the subset of contacts the user shared with the app.\n *\n * @since 1.0.0\n */\n find(options: ContactFindOptions): Promise<ContactFindResult>;\n\n /**\n * Persists a new contact or updates an existing one (matched by `contact.id`).\n * Resolves with the full saved contact.\n *\n * Requests the READ/WRITE_CONTACTS (Android) / Contacts (iOS) permission\n * internally.\n *\n * **iOS 18+:** works under Limited Access: new contacts are added to the\n * app's accessible set; updating requires the target contact to be in that\n * set (otherwise the call rejects with `OS-PLUG-CONT-0001`).\n *\n * @since 1.0.0\n */\n save(options: ContactSaveOptions): Promise<Contact>;\n\n /**\n * Removes the contact with the given `id` from the device contacts database.\n * Rejects with `OS-PLUG-CONT-0001` when no contact has that id (on iOS 18+\n * Limited Access, also when the contact is outside the accessible set).\n *\n * Requests the READ/WRITE_CONTACTS (Android) / Contacts (iOS) permission\n * internally.\n *\n * @since 1.0.0\n */\n remove(options: ContactRemoveOptions): Promise<void>;\n\n /**\n * Launches the native contact picker UI and resolves with the contact the\n * user selects. Rejects with `OS-PLUG-CONT-0006` if the user cancels.\n *\n * On iOS the system picker requires no permission and always shows the full\n * contact list, even under iOS 18+ Limited Access (the picked contact is\n * returned without joining the app's accessible set). On Android the\n * READ_CONTACTS permission is requested internally to read the picked\n * contact's details.\n *\n * @since 1.0.0\n */\n pickContact(): Promise<Contact>;\n}\n\n/**\n * The set of contact fields a {@link ContactsPlugin.find} call can search\n * against or request back. Mirrors the legacy Cordova `ContactFieldType`\n * string values exactly.\n *\n * @since 1.0.0\n */\nexport type ContactFieldType =\n | 'addresses'\n | 'birthday'\n | 'categories'\n | 'country'\n | 'department'\n | 'displayName'\n | 'emails'\n | 'familyName'\n | 'formatted'\n | 'givenName'\n | 'honorificPrefix'\n | 'honorificSuffix'\n | 'id'\n | 'ims'\n | 'locality'\n | 'middleName'\n | 'name'\n | 'nickname'\n | 'note'\n | 'organizations'\n | 'phoneNumbers'\n | 'photos'\n | 'postalCode'\n | 'region'\n | 'streetAddress'\n | 'title'\n | 'urls';\n\n/**\n * Search options accepted by {@link ContactsPlugin.find}.\n *\n * @since 1.0.0\n */\nexport interface ContactFindOptions {\n /**\n * Fields to search against. Pass `['*']` to match every field. An empty\n * array is invalid and rejects with `OS-PLUG-CONT-0001`. The `id` field\n * matches by exact identifier; all other fields match case-insensitive\n * substrings. `photos` and `categories` are not searchable.\n *\n * @since 1.0.0\n */\n fields: ContactFieldType[];\n\n /**\n * Search string matched (case-insensitively) against the selected `fields`.\n * An empty/omitted filter returns every contact.\n *\n * @since 1.0.0\n */\n filter?: string;\n\n /**\n * When `true`, returns every match; when `false` (default), returns at most\n * one contact.\n *\n * @since 1.0.0\n */\n multiple?: boolean;\n\n /**\n * If set, each returned {@link Contact} only includes these fields (plus the\n * always-present `id`).\n *\n * @since 1.0.0\n */\n desiredFields?: ContactFieldType[];\n\n /**\n * OutSystems extension: when `true`, only contacts that have at least one\n * phone number are returned. Defaults to `false`.\n *\n * @since 1.0.0\n */\n hasPhoneNumber?: boolean;\n}\n\n/**\n * Result of a {@link ContactsPlugin.find} call.\n *\n * @since 1.0.0\n */\nexport interface ContactFindResult {\n /**\n * The contacts matching the search criteria.\n *\n * @since 1.0.0\n */\n contacts: Contact[];\n}\n\n/**\n * Options accepted by {@link ContactsPlugin.save}.\n *\n * @since 1.0.0\n */\nexport interface ContactSaveOptions {\n /**\n * The contact to create (no `id`) or update (existing `id`).\n *\n * Update semantics: every field present on the contact replaces the stored\n * value entirely (e.g. `name` replaces the whole structured name,\n * `phoneNumbers` replaces all phone numbers); omitted fields are left\n * unchanged.\n *\n * @since 1.0.0\n */\n contact: Contact;\n}\n\n/**\n * Options accepted by {@link ContactsPlugin.remove}.\n *\n * @since 1.0.0\n */\nexport interface ContactRemoveOptions {\n /**\n * The native id of the contact to remove.\n *\n * @since 1.0.0\n */\n id: string;\n}\n\n/**\n * A single device contact.\n *\n * @since 1.0.0\n */\nexport interface Contact {\n /**\n * Globally unique, platform-assigned identifier. Absent for contacts not yet\n * saved to the device.\n *\n * @since 1.0.0\n */\n id?: string;\n\n /**\n * Android raw-contact id backing this aggregated contact. iOS leaves this\n * unset.\n *\n * @since 1.0.0\n */\n rawId?: string;\n\n /**\n * Name suitable for display to end users.\n *\n * @since 1.0.0\n */\n displayName?: string;\n\n /**\n * The structured name components.\n *\n * @since 1.0.0\n */\n name?: ContactName;\n\n /**\n * A casual name by which to address the contact.\n *\n * @since 1.0.0\n */\n nickname?: string;\n\n /**\n * The contact's phone numbers.\n *\n * @since 1.0.0\n */\n phoneNumbers?: ContactField[];\n\n /**\n * The contact's email addresses.\n *\n * @since 1.0.0\n */\n emails?: ContactField[];\n\n /**\n * The contact's postal addresses.\n *\n * @since 1.0.0\n */\n addresses?: ContactAddress[];\n\n /**\n * The contact's instant-messaging handles.\n *\n * @since 1.0.0\n */\n ims?: ContactField[];\n\n /**\n * The contact's organizations.\n *\n * @since 1.0.0\n */\n organizations?: ContactOrganization[];\n\n /**\n * The contact's birthday as epoch milliseconds.\n *\n * @since 1.0.0\n */\n birthday?: number;\n\n /**\n * A free-form note about the contact.\n *\n * **iOS:** not supported by default: reading/writing a contact's note\n * requires Apple's restricted `com.apple.developer.contacts.notes`\n * entitlement. Without it the field is omitted on read and ignored on save.\n * Android has no such restriction.\n *\n * @since 1.0.0\n */\n note?: string;\n\n /**\n * The contact's photos. Reads return `type: 'url'` with the `value`\n * holding a reference to the image, never image bytes: on Android the\n * contact's `content://` photo URI, on iOS the path of a copy written to\n * the app's temporary directory (cleared by the system). On save, the first entry is\n * applied: pass `type: 'base64'` with base64 data, or `type: 'url'` with a\n * local `file://`/`content://` URI to import.\n *\n * @since 1.0.0\n */\n photos?: ContactField[];\n\n /**\n * User-defined categories associated with the contact. Read-only: populated\n * from the contact's group memberships on Android, never returned on iOS\n * (the Contacts framework has no equivalent), and ignored on save.\n *\n * @since 1.0.0\n */\n categories?: ContactField[];\n\n /**\n * Web pages associated with the contact.\n *\n * @since 1.0.0\n */\n urls?: ContactField[];\n}\n\n/**\n * Structured name of a {@link Contact}.\n *\n * @since 1.0.0\n */\nexport interface ContactName {\n /**\n * The complete formatted name.\n *\n * @since 1.0.0\n */\n formatted?: string;\n\n /**\n * Family (last) name.\n *\n * @since 1.0.0\n */\n familyName?: string;\n\n /**\n * Given (first) name.\n *\n * @since 1.0.0\n */\n givenName?: string;\n\n /**\n * Middle name.\n *\n * @since 1.0.0\n */\n middleName?: string;\n\n /**\n * Honorific prefix (e.g. `Mr.`, `Dr.`).\n *\n * @since 1.0.0\n */\n honorificPrefix?: string;\n\n /**\n * Honorific suffix (e.g. `Esq.`).\n *\n * @since 1.0.0\n */\n honorificSuffix?: string;\n}\n\n/**\n * A generic, repeatable contact field (phone number, email, IM, photo, URL,\n * category).\n *\n * @since 1.0.0\n */\nexport interface ContactField {\n /**\n * The kind of field, e.g. `home`, `work`, `mobile`. For photos, `url` or\n * `base64`.\n *\n * @since 1.0.0\n */\n type?: string;\n\n /**\n * The field value (phone number, email address, URI, etc.).\n *\n * @since 1.0.0\n */\n value?: string;\n\n /**\n * `true` if this is the contact's preferred value for the field.\n *\n * @since 1.0.0\n */\n pref?: boolean;\n\n /**\n * Platform-assigned id of this individual field entry.\n *\n * @since 1.0.0\n */\n id?: string;\n}\n\n/**\n * A postal address of a {@link Contact}.\n *\n * @since 1.0.0\n */\nexport interface ContactAddress {\n /**\n * Platform-assigned id of this address entry.\n *\n * @since 1.0.0\n */\n id?: string;\n\n /**\n * `true` if this is the contact's preferred address.\n *\n * @since 1.0.0\n */\n pref?: boolean;\n\n /**\n * The kind of address, e.g. `home`, `work`.\n *\n * @since 1.0.0\n */\n type?: string;\n\n /**\n * The full address formatted for display.\n *\n * @since 1.0.0\n */\n formatted?: string;\n\n /**\n * The street address.\n *\n * @since 1.0.0\n */\n streetAddress?: string;\n\n /**\n * The city or locality.\n *\n * @since 1.0.0\n */\n locality?: string;\n\n /**\n * The state or region.\n *\n * @since 1.0.0\n */\n region?: string;\n\n /**\n * The ZIP or postal code.\n *\n * @since 1.0.0\n */\n postalCode?: string;\n\n /**\n * The country name.\n *\n * @since 1.0.0\n */\n country?: string;\n}\n\n/**\n * An organization a {@link Contact} belongs to.\n *\n * @since 1.0.0\n */\nexport interface ContactOrganization {\n /**\n * Platform-assigned id of this organization entry. Android only; iOS\n * models the organization as flat contact properties without an id.\n *\n * @since 1.0.0\n */\n id?: string;\n\n /**\n * `true` if this is the contact's preferred organization.\n *\n * @since 1.0.0\n */\n pref?: boolean;\n\n /**\n * The kind of organization, e.g. `work`.\n *\n * @since 1.0.0\n */\n type?: string;\n\n /**\n * The organization name.\n *\n * @since 1.0.0\n */\n name?: string;\n\n /**\n * The department within the organization.\n *\n * @since 1.0.0\n */\n department?: string;\n\n /**\n * The contact's title at the organization.\n *\n * @since 1.0.0\n */\n title?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,QAAQ,GAAG,cAAc,CAAiB,UAAU,EAAE;IAC1D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;CAC5D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { ContactsPlugin } from './definitions';\n\nconst Contacts = registerPlugin<ContactsPlugin>('Contacts', {\n web: () => import('./web').then((m) => new m.ContactsWeb()),\n});\n\nexport * from './definitions';\nexport { Contacts };\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { Contact, ContactFindOptions, ContactFindResult, ContactRemoveOptions, ContactSaveOptions, ContactsPlugin } from './definitions';
|
|
3
|
+
/**
|
|
4
|
+
* Web implementation. The browser has no standardized, broadly-available
|
|
5
|
+
* contacts database API (the Contact Picker API is limited, gated, and
|
|
6
|
+
* read-only), so every method throws `unimplemented()`. The plugin is
|
|
7
|
+
* native-only on iOS and Android.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ContactsWeb extends WebPlugin implements ContactsPlugin {
|
|
10
|
+
find(_options: ContactFindOptions): Promise<ContactFindResult>;
|
|
11
|
+
save(_options: ContactSaveOptions): Promise<Contact>;
|
|
12
|
+
remove(_options: ContactRemoveOptions): Promise<void>;
|
|
13
|
+
pickContact(): Promise<Contact>;
|
|
14
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
/**
|
|
3
|
+
* Web implementation. The browser has no standardized, broadly-available
|
|
4
|
+
* contacts database API (the Contact Picker API is limited, gated, and
|
|
5
|
+
* read-only), so every method throws `unimplemented()`. The plugin is
|
|
6
|
+
* native-only on iOS and Android.
|
|
7
|
+
*/
|
|
8
|
+
export class ContactsWeb extends WebPlugin {
|
|
9
|
+
async find(_options) {
|
|
10
|
+
throw this.unimplemented('Contacts.find() is not available on web.');
|
|
11
|
+
}
|
|
12
|
+
async save(_options) {
|
|
13
|
+
throw this.unimplemented('Contacts.save() is not available on web.');
|
|
14
|
+
}
|
|
15
|
+
async remove(_options) {
|
|
16
|
+
throw this.unimplemented('Contacts.remove() is not available on web.');
|
|
17
|
+
}
|
|
18
|
+
async pickContact() {
|
|
19
|
+
throw this.unimplemented('Contacts.pickContact() is not available on web.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C;;;;;GAKG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,KAAK,CAAC,IAAI,CAAC,QAA4B;QACrC,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAA4B;QACrC,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAA8B;QACzC,MAAM,IAAI,CAAC,aAAa,CAAC,4CAA4C,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC,CAAC;IAC9E,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n Contact,\n ContactFindOptions,\n ContactFindResult,\n ContactRemoveOptions,\n ContactSaveOptions,\n ContactsPlugin,\n} from './definitions';\n\n/**\n * Web implementation. The browser has no standardized, broadly-available\n * contacts database API (the Contact Picker API is limited, gated, and\n * read-only), so every method throws `unimplemented()`. The plugin is\n * native-only on iOS and Android.\n */\nexport class ContactsWeb extends WebPlugin implements ContactsPlugin {\n async find(_options: ContactFindOptions): Promise<ContactFindResult> {\n throw this.unimplemented('Contacts.find() is not available on web.');\n }\n\n async save(_options: ContactSaveOptions): Promise<Contact> {\n throw this.unimplemented('Contacts.save() is not available on web.');\n }\n\n async remove(_options: ContactRemoveOptions): Promise<void> {\n throw this.unimplemented('Contacts.remove() is not available on web.');\n }\n\n async pickContact(): Promise<Contact> {\n throw this.unimplemented('Contacts.pickContact() is not available on web.');\n }\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
const Contacts = core.registerPlugin('Contacts', {
|
|
6
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.ContactsWeb()),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Web implementation. The browser has no standardized, broadly-available
|
|
11
|
+
* contacts database API (the Contact Picker API is limited, gated, and
|
|
12
|
+
* read-only), so every method throws `unimplemented()`. The plugin is
|
|
13
|
+
* native-only on iOS and Android.
|
|
14
|
+
*/
|
|
15
|
+
class ContactsWeb extends core.WebPlugin {
|
|
16
|
+
async find(_options) {
|
|
17
|
+
throw this.unimplemented('Contacts.find() is not available on web.');
|
|
18
|
+
}
|
|
19
|
+
async save(_options) {
|
|
20
|
+
throw this.unimplemented('Contacts.save() is not available on web.');
|
|
21
|
+
}
|
|
22
|
+
async remove(_options) {
|
|
23
|
+
throw this.unimplemented('Contacts.remove() is not available on web.');
|
|
24
|
+
}
|
|
25
|
+
async pickContact() {
|
|
26
|
+
throw this.unimplemented('Contacts.pickContact() is not available on web.');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
31
|
+
__proto__: null,
|
|
32
|
+
ContactsWeb: ContactsWeb
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
exports.Contacts = Contacts;
|
|
36
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Contacts = registerPlugin('Contacts', {\n web: () => import('./web').then((m) => new m.ContactsWeb()),\n});\nexport * from './definitions';\nexport { Contacts };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation. The browser has no standardized, broadly-available\n * contacts database API (the Contact Picker API is limited, gated, and\n * read-only), so every method throws `unimplemented()`. The plugin is\n * native-only on iOS and Android.\n */\nexport class ContactsWeb extends WebPlugin {\n async find(_options) {\n throw this.unimplemented('Contacts.find() is not available on web.');\n }\n async save(_options) {\n throw this.unimplemented('Contacts.save() is not available on web.');\n }\n async remove(_options) {\n throw this.unimplemented('Contacts.remove() is not available on web.');\n }\n async pickContact() {\n throw this.unimplemented('Contacts.pickContact() is not available on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;AAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/D,CAAC;;ACFD;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAW,SAASC,cAAS,CAAC;AAC3C,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;AACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC;AAC5E,IAAI;AACJ,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;AACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC;AAC5E,IAAI;AACJ,IAAI,MAAM,MAAM,CAAC,QAAQ,EAAE;AAC3B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4CAA4C,CAAC;AAC9E,IAAI;AACJ,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC;AACnF,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var capacitorContacts = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Contacts = core.registerPlugin('Contacts', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.ContactsWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Web implementation. The browser has no standardized, broadly-available
|
|
10
|
+
* contacts database API (the Contact Picker API is limited, gated, and
|
|
11
|
+
* read-only), so every method throws `unimplemented()`. The plugin is
|
|
12
|
+
* native-only on iOS and Android.
|
|
13
|
+
*/
|
|
14
|
+
class ContactsWeb extends core.WebPlugin {
|
|
15
|
+
async find(_options) {
|
|
16
|
+
throw this.unimplemented('Contacts.find() is not available on web.');
|
|
17
|
+
}
|
|
18
|
+
async save(_options) {
|
|
19
|
+
throw this.unimplemented('Contacts.save() is not available on web.');
|
|
20
|
+
}
|
|
21
|
+
async remove(_options) {
|
|
22
|
+
throw this.unimplemented('Contacts.remove() is not available on web.');
|
|
23
|
+
}
|
|
24
|
+
async pickContact() {
|
|
25
|
+
throw this.unimplemented('Contacts.pickContact() is not available on web.');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
30
|
+
__proto__: null,
|
|
31
|
+
ContactsWeb: ContactsWeb
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
exports.Contacts = Contacts;
|
|
35
|
+
|
|
36
|
+
return exports;
|
|
37
|
+
|
|
38
|
+
})({}, capacitorExports);
|
|
39
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Contacts = registerPlugin('Contacts', {\n web: () => import('./web').then((m) => new m.ContactsWeb()),\n});\nexport * from './definitions';\nexport { Contacts };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation. The browser has no standardized, broadly-available\n * contacts database API (the Contact Picker API is limited, gated, and\n * read-only), so every method throws `unimplemented()`. The plugin is\n * native-only on iOS and Android.\n */\nexport class ContactsWeb extends WebPlugin {\n async find(_options) {\n throw this.unimplemented('Contacts.find() is not available on web.');\n }\n async save(_options) {\n throw this.unimplemented('Contacts.save() is not available on web.');\n }\n async remove(_options) {\n throw this.unimplemented('Contacts.remove() is not available on web.');\n }\n async pickContact() {\n throw this.unimplemented('Contacts.pickContact() is not available on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;IAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,CAAC;;ICFD;IACA;IACA;IACA;IACA;IACA;IACO,MAAM,WAAW,SAASC,cAAS,CAAC;IAC3C,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;IACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC;IAC5E,IAAI;IACJ,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;IACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC;IAC5E,IAAI;IACJ,IAAI,MAAM,MAAM,CAAC,QAAQ,EAAE;IAC3B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4CAA4C,CAAC;IAC9E,IAAI;IACJ,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC;IACnF,IAAI;IACJ;;;;;;;;;;;;;;;"}
|