@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,18 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CapacitorContacts'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '15.0'
|
|
15
|
+
s.frameworks = 'Contacts', 'ContactsUI'
|
|
16
|
+
s.dependency 'Capacitor'
|
|
17
|
+
s.swift_version = '5.1'
|
|
18
|
+
end
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
OutSystems Capacitor Contacts Plugin
|
|
2
|
+
Copyright 2026-present OutSystems
|
|
3
|
+
|
|
4
|
+
This product includes software ported from Apache Cordova
|
|
5
|
+
cordova-plugin-contacts (https://github.com/apache/cordova-plugin-contacts),
|
|
6
|
+
Copyright 2012 The Apache Software Foundation, licensed under the
|
|
7
|
+
Apache License, Version 2.0.
|
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "CapacitorContacts",
|
|
6
|
+
platforms: [.iOS(.v15)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "CapacitorContacts",
|
|
10
|
+
targets: ["ContactsPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "ContactsPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/ContactsPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "ContactsPluginTests",
|
|
25
|
+
dependencies: ["ContactsPlugin"],
|
|
26
|
+
path: "ios/Tests/ContactsPluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
# @capacitor/contacts
|
|
2
|
+
|
|
3
|
+
Access, search, pick, create, update and remove device contacts.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
To use npm
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @capacitor/contacts
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
To use yarn
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @capacitor/contacts
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Sync native files
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx cap sync
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## iOS
|
|
26
|
+
|
|
27
|
+
Add the `NSContactsUsageDescription` key to your app's `Info.plist` and
|
|
28
|
+
describe why the app accesses the user's contacts; iOS crashes on first
|
|
29
|
+
contacts access without it:
|
|
30
|
+
|
|
31
|
+
```xml
|
|
32
|
+
<key>NSContactsUsageDescription</key>
|
|
33
|
+
<string>We need access to contacts to search, save and remove them.</string>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Notes:
|
|
37
|
+
|
|
38
|
+
- The plugin uses the modern **Contacts framework** (`CNContactStore`,
|
|
39
|
+
never the deprecated AddressBook APIs), so it fully supports iOS 18+
|
|
40
|
+
**Limited Access**: `find`, `save` and `remove` operate on the subset the
|
|
41
|
+
user shared with the app, and `pickContact` presents the system picker
|
|
42
|
+
(which needs no permission and always shows the full contact list).
|
|
43
|
+
- The `note` field is not supported on iOS: reading or writing it requires
|
|
44
|
+
Apple's restricted `com.apple.developer.contacts.notes` entitlement. The
|
|
45
|
+
field is omitted on read and ignored on save.
|
|
46
|
+
- Contact `id`s are opaque `CNContact` identifiers; ids persisted by the
|
|
47
|
+
legacy AddressBook-based Cordova plugin do not resolve after migration.
|
|
48
|
+
|
|
49
|
+
## Android
|
|
50
|
+
|
|
51
|
+
The plugin declares `READ_CONTACTS` and `WRITE_CONTACTS` in its own
|
|
52
|
+
manifest; Gradle manifest merging adds them to your app automatically. Each
|
|
53
|
+
method requests the runtime permission it needs the first time it runs;
|
|
54
|
+
read for `find`/`pickContact`, read + write for `save`/`remove`.
|
|
55
|
+
|
|
56
|
+
## Permission model
|
|
57
|
+
|
|
58
|
+
This plugin intentionally exposes **no** `checkPermissions()` /
|
|
59
|
+
`requestPermissions()` methods: permissions are requested implicitly by each
|
|
60
|
+
method, matching the legacy `cordova-plugin-contacts` behavior. A call
|
|
61
|
+
rejects with `OS-PLUG-CONT-0020` when the user denies access.
|
|
62
|
+
|
|
63
|
+
## Errors
|
|
64
|
+
|
|
65
|
+
Every rejection carries a structured code + message:
|
|
66
|
+
|
|
67
|
+
| Code | Meaning |
|
|
68
|
+
| ------------------- | ----------------------------------- |
|
|
69
|
+
| `OS-PLUG-CONT-0000` | Unknown error |
|
|
70
|
+
| `OS-PLUG-CONT-0001` | Invalid argument (e.g. unknown id) |
|
|
71
|
+
| `OS-PLUG-CONT-0002` | Timeout (reserved, currently unused) |
|
|
72
|
+
| `OS-PLUG-CONT-0003` | Pending operation (e.g. picker already open) |
|
|
73
|
+
| `OS-PLUG-CONT-0004` | I/O error |
|
|
74
|
+
| `OS-PLUG-CONT-0005` | Not supported |
|
|
75
|
+
| `OS-PLUG-CONT-0006` | Operation cancelled (picker closed) |
|
|
76
|
+
| `OS-PLUG-CONT-0020` | Permission denied |
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { Contacts } from '@capacitor/contacts';
|
|
82
|
+
|
|
83
|
+
// Search every field for "ada" and return all matches with a phone number
|
|
84
|
+
const { contacts } = await Contacts.find({
|
|
85
|
+
fields: ['*'],
|
|
86
|
+
filter: 'ada',
|
|
87
|
+
multiple: true,
|
|
88
|
+
hasPhoneNumber: true,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Create a contact
|
|
92
|
+
const saved = await Contacts.save({
|
|
93
|
+
contact: {
|
|
94
|
+
name: { givenName: 'Ada', familyName: 'Lovelace' },
|
|
95
|
+
phoneNumbers: [{ type: 'mobile', value: '+351910000000' }],
|
|
96
|
+
emails: [{ type: 'home', value: 'ada@example.com' }],
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Update it (id present -> update)
|
|
101
|
+
await Contacts.save({ contact: { ...saved, nickname: 'Countess' } });
|
|
102
|
+
|
|
103
|
+
// Pick a contact with the native picker
|
|
104
|
+
const picked = await Contacts.pickContact();
|
|
105
|
+
|
|
106
|
+
// Remove it by id
|
|
107
|
+
await Contacts.remove({ id: saved.id! });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## API
|
|
111
|
+
|
|
112
|
+
<docgen-index>
|
|
113
|
+
|
|
114
|
+
* [`find(...)`](#find)
|
|
115
|
+
* [`save(...)`](#save)
|
|
116
|
+
* [`remove(...)`](#remove)
|
|
117
|
+
* [`pickContact()`](#pickcontact)
|
|
118
|
+
* [Interfaces](#interfaces)
|
|
119
|
+
* [Type Aliases](#type-aliases)
|
|
120
|
+
|
|
121
|
+
</docgen-index>
|
|
122
|
+
|
|
123
|
+
<docgen-api>
|
|
124
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
125
|
+
|
|
126
|
+
### find(...)
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
find(options: ContactFindOptions) => Promise<ContactFindResult>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Queries the device contacts database and returns the matching contacts.
|
|
133
|
+
|
|
134
|
+
Requests the READ_CONTACTS (Android) / Contacts (iOS) permission internally
|
|
135
|
+
the first time it runs; there is no separate permission method.
|
|
136
|
+
|
|
137
|
+
**iOS 18+:** under Limited Access the search runs against (and returns
|
|
138
|
+
only) the subset of contacts the user shared with the app.
|
|
139
|
+
|
|
140
|
+
| Param | Type |
|
|
141
|
+
| ------------- | ----------------------------------------------------------------- |
|
|
142
|
+
| **`options`** | <code><a href="#contactfindoptions">ContactFindOptions</a></code> |
|
|
143
|
+
|
|
144
|
+
**Returns:** <code>Promise<<a href="#contactfindresult">ContactFindResult</a>></code>
|
|
145
|
+
|
|
146
|
+
**Since:** 1.0.0
|
|
147
|
+
|
|
148
|
+
--------------------
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### save(...)
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
save(options: ContactSaveOptions) => Promise<Contact>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Persists a new contact or updates an existing one (matched by `contact.id`).
|
|
158
|
+
Resolves with the full saved contact.
|
|
159
|
+
|
|
160
|
+
Requests the READ/WRITE_CONTACTS (Android) / Contacts (iOS) permission
|
|
161
|
+
internally.
|
|
162
|
+
|
|
163
|
+
**iOS 18+:** works under Limited Access: new contacts are added to the
|
|
164
|
+
app's accessible set; updating requires the target contact to be in that
|
|
165
|
+
set (otherwise the call rejects with `OS-PLUG-CONT-0001`).
|
|
166
|
+
|
|
167
|
+
| Param | Type |
|
|
168
|
+
| ------------- | ----------------------------------------------------------------- |
|
|
169
|
+
| **`options`** | <code><a href="#contactsaveoptions">ContactSaveOptions</a></code> |
|
|
170
|
+
|
|
171
|
+
**Returns:** <code>Promise<<a href="#contact">Contact</a>></code>
|
|
172
|
+
|
|
173
|
+
**Since:** 1.0.0
|
|
174
|
+
|
|
175
|
+
--------------------
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
### remove(...)
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
remove(options: ContactRemoveOptions) => Promise<void>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Removes the contact with the given `id` from the device contacts database.
|
|
185
|
+
Rejects with `OS-PLUG-CONT-0001` when no contact has that id (on iOS 18+
|
|
186
|
+
Limited Access, also when the contact is outside the accessible set).
|
|
187
|
+
|
|
188
|
+
Requests the READ/WRITE_CONTACTS (Android) / Contacts (iOS) permission
|
|
189
|
+
internally.
|
|
190
|
+
|
|
191
|
+
| Param | Type |
|
|
192
|
+
| ------------- | --------------------------------------------------------------------- |
|
|
193
|
+
| **`options`** | <code><a href="#contactremoveoptions">ContactRemoveOptions</a></code> |
|
|
194
|
+
|
|
195
|
+
**Since:** 1.0.0
|
|
196
|
+
|
|
197
|
+
--------------------
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
### pickContact()
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
pickContact() => Promise<Contact>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Launches the native contact picker UI and resolves with the contact the
|
|
207
|
+
user selects. Rejects with `OS-PLUG-CONT-0006` if the user cancels.
|
|
208
|
+
|
|
209
|
+
On iOS the system picker requires no permission and always shows the full
|
|
210
|
+
contact list, even under iOS 18+ Limited Access (the picked contact is
|
|
211
|
+
returned without joining the app's accessible set). On Android the
|
|
212
|
+
READ_CONTACTS permission is requested internally to read the picked
|
|
213
|
+
contact's details.
|
|
214
|
+
|
|
215
|
+
**Returns:** <code>Promise<<a href="#contact">Contact</a>></code>
|
|
216
|
+
|
|
217
|
+
**Since:** 1.0.0
|
|
218
|
+
|
|
219
|
+
--------------------
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
### Interfaces
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
#### ContactFindResult
|
|
226
|
+
|
|
227
|
+
Result of a {@link ContactsPlugin.find} call.
|
|
228
|
+
|
|
229
|
+
| Prop | Type | Description | Since |
|
|
230
|
+
| -------------- | ---------------------- | ------------------------------------------ | ----- |
|
|
231
|
+
| **`contacts`** | <code>Contact[]</code> | The contacts matching the search criteria. | 1.0.0 |
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
#### Contact
|
|
235
|
+
|
|
236
|
+
A single device contact.
|
|
237
|
+
|
|
238
|
+
| Prop | Type | Description | Since |
|
|
239
|
+
| ------------------- | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
240
|
+
| **`id`** | <code>string</code> | Globally unique, platform-assigned identifier. Absent for contacts not yet saved to the device. | 1.0.0 |
|
|
241
|
+
| **`rawId`** | <code>string</code> | Android raw-contact id backing this aggregated contact. iOS leaves this unset. | 1.0.0 |
|
|
242
|
+
| **`displayName`** | <code>string</code> | Name suitable for display to end users. | 1.0.0 |
|
|
243
|
+
| **`name`** | <code><a href="#contactname">ContactName</a></code> | The structured name components. | 1.0.0 |
|
|
244
|
+
| **`nickname`** | <code>string</code> | A casual name by which to address the contact. | 1.0.0 |
|
|
245
|
+
| **`phoneNumbers`** | <code>ContactField[]</code> | The contact's phone numbers. | 1.0.0 |
|
|
246
|
+
| **`emails`** | <code>ContactField[]</code> | The contact's email addresses. | 1.0.0 |
|
|
247
|
+
| **`addresses`** | <code>ContactAddress[]</code> | The contact's postal addresses. | 1.0.0 |
|
|
248
|
+
| **`ims`** | <code>ContactField[]</code> | The contact's instant-messaging handles. | 1.0.0 |
|
|
249
|
+
| **`organizations`** | <code>ContactOrganization[]</code> | The contact's organizations. | 1.0.0 |
|
|
250
|
+
| **`birthday`** | <code>number</code> | The contact's birthday as epoch milliseconds. | 1.0.0 |
|
|
251
|
+
| **`note`** | <code>string</code> | A free-form note about the contact. **iOS:** not supported by default: reading/writing a contact's note requires Apple's restricted `com.apple.developer.contacts.notes` entitlement. Without it the field is omitted on read and ignored on save. Android has no such restriction. | 1.0.0 |
|
|
252
|
+
| **`photos`** | <code>ContactField[]</code> | The contact's photos. Reads return `type: 'url'` with the `value` holding a reference to the image, never image bytes: on Android the contact's `content://` photo URI, on iOS the path of a copy written to the app's temporary directory (cleared by the system). On save, the first entry is applied: pass `type: 'base64'` with base64 data, or `type: 'url'` with a local `file://`/`content://` URI to import. | 1.0.0 |
|
|
253
|
+
| **`categories`** | <code>ContactField[]</code> | User-defined categories associated with the contact. Read-only: populated from the contact's group memberships on Android, never returned on iOS (the Contacts framework has no equivalent), and ignored on save. | 1.0.0 |
|
|
254
|
+
| **`urls`** | <code>ContactField[]</code> | Web pages associated with the contact. | 1.0.0 |
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
#### ContactName
|
|
258
|
+
|
|
259
|
+
Structured name of a {@link <a href="#contact">Contact</a>}.
|
|
260
|
+
|
|
261
|
+
| Prop | Type | Description | Since |
|
|
262
|
+
| --------------------- | ------------------- | ------------------------------------- | ----- |
|
|
263
|
+
| **`formatted`** | <code>string</code> | The complete formatted name. | 1.0.0 |
|
|
264
|
+
| **`familyName`** | <code>string</code> | Family (last) name. | 1.0.0 |
|
|
265
|
+
| **`givenName`** | <code>string</code> | Given (first) name. | 1.0.0 |
|
|
266
|
+
| **`middleName`** | <code>string</code> | Middle name. | 1.0.0 |
|
|
267
|
+
| **`honorificPrefix`** | <code>string</code> | Honorific prefix (e.g. `Mr.`, `Dr.`). | 1.0.0 |
|
|
268
|
+
| **`honorificSuffix`** | <code>string</code> | Honorific suffix (e.g. `Esq.`). | 1.0.0 |
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
#### ContactField
|
|
272
|
+
|
|
273
|
+
A generic, repeatable contact field (phone number, email, IM, photo, URL,
|
|
274
|
+
category).
|
|
275
|
+
|
|
276
|
+
| Prop | Type | Description | Since |
|
|
277
|
+
| ----------- | -------------------- | -------------------------------------------------------------------------------- | ----- |
|
|
278
|
+
| **`type`** | <code>string</code> | The kind of field, e.g. `home`, `work`, `mobile`. For photos, `url` or `base64`. | 1.0.0 |
|
|
279
|
+
| **`value`** | <code>string</code> | The field value (phone number, email address, URI, etc.). | 1.0.0 |
|
|
280
|
+
| **`pref`** | <code>boolean</code> | `true` if this is the contact's preferred value for the field. | 1.0.0 |
|
|
281
|
+
| **`id`** | <code>string</code> | Platform-assigned id of this individual field entry. | 1.0.0 |
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
#### ContactAddress
|
|
285
|
+
|
|
286
|
+
A postal address of a {@link <a href="#contact">Contact</a>}.
|
|
287
|
+
|
|
288
|
+
| Prop | Type | Description | Since |
|
|
289
|
+
| ------------------- | -------------------- | -------------------------------------------------- | ----- |
|
|
290
|
+
| **`id`** | <code>string</code> | Platform-assigned id of this address entry. | 1.0.0 |
|
|
291
|
+
| **`pref`** | <code>boolean</code> | `true` if this is the contact's preferred address. | 1.0.0 |
|
|
292
|
+
| **`type`** | <code>string</code> | The kind of address, e.g. `home`, `work`. | 1.0.0 |
|
|
293
|
+
| **`formatted`** | <code>string</code> | The full address formatted for display. | 1.0.0 |
|
|
294
|
+
| **`streetAddress`** | <code>string</code> | The street address. | 1.0.0 |
|
|
295
|
+
| **`locality`** | <code>string</code> | The city or locality. | 1.0.0 |
|
|
296
|
+
| **`region`** | <code>string</code> | The state or region. | 1.0.0 |
|
|
297
|
+
| **`postalCode`** | <code>string</code> | The ZIP or postal code. | 1.0.0 |
|
|
298
|
+
| **`country`** | <code>string</code> | The country name. | 1.0.0 |
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
#### ContactOrganization
|
|
302
|
+
|
|
303
|
+
An organization a {@link <a href="#contact">Contact</a>} belongs to.
|
|
304
|
+
|
|
305
|
+
| Prop | Type | Description | Since |
|
|
306
|
+
| ---------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ----- |
|
|
307
|
+
| **`id`** | <code>string</code> | Platform-assigned id of this organization entry. Android only; iOS models the organization as flat contact properties without an id. | 1.0.0 |
|
|
308
|
+
| **`pref`** | <code>boolean</code> | `true` if this is the contact's preferred organization. | 1.0.0 |
|
|
309
|
+
| **`type`** | <code>string</code> | The kind of organization, e.g. `work`. | 1.0.0 |
|
|
310
|
+
| **`name`** | <code>string</code> | The organization name. | 1.0.0 |
|
|
311
|
+
| **`department`** | <code>string</code> | The department within the organization. | 1.0.0 |
|
|
312
|
+
| **`title`** | <code>string</code> | The contact's title at the organization. | 1.0.0 |
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
#### ContactFindOptions
|
|
316
|
+
|
|
317
|
+
Search options accepted by {@link ContactsPlugin.find}.
|
|
318
|
+
|
|
319
|
+
| Prop | Type | Description | Since |
|
|
320
|
+
| -------------------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
321
|
+
| **`fields`** | <code>ContactFieldType[]</code> | Fields to search against. Pass `['*']` to match every field. An empty array is invalid and rejects with `OS-PLUG-CONT-0001`. The `id` field matches by exact identifier; all other fields match case-insensitive substrings. `photos` and `categories` are not searchable. | 1.0.0 |
|
|
322
|
+
| **`filter`** | <code>string</code> | Search string matched (case-insensitively) against the selected `fields`. An empty/omitted filter returns every contact. | 1.0.0 |
|
|
323
|
+
| **`multiple`** | <code>boolean</code> | When `true`, returns every match; when `false` (default), returns at most one contact. | 1.0.0 |
|
|
324
|
+
| **`desiredFields`** | <code>ContactFieldType[]</code> | If set, each returned {@link <a href="#contact">Contact</a>} only includes these fields (plus the always-present `id`). | 1.0.0 |
|
|
325
|
+
| **`hasPhoneNumber`** | <code>boolean</code> | OutSystems extension: when `true`, only contacts that have at least one phone number are returned. Defaults to `false`. | 1.0.0 |
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
#### ContactSaveOptions
|
|
329
|
+
|
|
330
|
+
Options accepted by {@link ContactsPlugin.save}.
|
|
331
|
+
|
|
332
|
+
| Prop | Type | Description | Since |
|
|
333
|
+
| ------------- | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
334
|
+
| **`contact`** | <code><a href="#contact">Contact</a></code> | The contact to create (no `id`) or update (existing `id`). Update semantics: every field present on the contact replaces the stored value entirely (e.g. `name` replaces the whole structured name, `phoneNumbers` replaces all phone numbers); omitted fields are left unchanged. | 1.0.0 |
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
#### ContactRemoveOptions
|
|
338
|
+
|
|
339
|
+
Options accepted by {@link ContactsPlugin.remove}.
|
|
340
|
+
|
|
341
|
+
| Prop | Type | Description | Since |
|
|
342
|
+
| -------- | ------------------- | --------------------------------------- | ----- |
|
|
343
|
+
| **`id`** | <code>string</code> | The native id of the contact to remove. | 1.0.0 |
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
### Type Aliases
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
#### ContactFieldType
|
|
350
|
+
|
|
351
|
+
The set of contact fields a {@link ContactsPlugin.find} call can search
|
|
352
|
+
against or request back. Mirrors the legacy Cordova `ContactFieldType`
|
|
353
|
+
string values exactly.
|
|
354
|
+
|
|
355
|
+
<code>'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'</code>
|
|
356
|
+
|
|
357
|
+
</docgen-api>
|