react-native-contacts 7.0.8 → 8.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/.tool-versions +1 -1
- package/android/build.gradle +28 -1
- package/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsProvider.java +123 -129
- package/android/src/main/java/com/rt2zz/reactnativecontacts/ReactNativeContacts.java +32 -16
- package/android/src/newarch/com/rt2zz/reactnativecontacts/ContactsManager.java +1388 -0
- package/android/src/{main/java → oldarch}/com/rt2zz/reactnativecontacts/ContactsManager.java +100 -88
- package/index.d.ts +10 -10
- package/index.ts +113 -0
- package/ios/RCTContacts/RCTContacts.h +12 -0
- package/ios/RCTContacts/{RCTContacts.m → RCTContacts.mm} +519 -39
- package/package.json +19 -4
- package/react-native-contacts.podspec +28 -8
- package/src/NativeContacts.ts +27 -0
- package/type.ts +62 -0
- package/index.js +0 -2
package/index.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { NativeModules } from "react-native";
|
|
2
|
+
import NativeContacts from "./src/NativeContacts";
|
|
3
|
+
import { Contact } from "./type";
|
|
4
|
+
|
|
5
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
6
|
+
const Contacts = isTurboModuleEnabled ? NativeContacts : NativeModules.Contacts;
|
|
7
|
+
|
|
8
|
+
async function getAll(): Promise<Contact[]> {
|
|
9
|
+
return Contacts.getAll();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function getAllWithoutPhotos(): Promise<Contact[]> {
|
|
13
|
+
return Contacts.getAllWithoutPhotos();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function getContactById(contactId: string): Promise<Contact | null> {
|
|
17
|
+
return Contacts.getContactById(contactId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function getCount(): Promise<number> {
|
|
21
|
+
return Contacts.getCount();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function getPhotoForId(contactId: string): Promise<string> {
|
|
25
|
+
return Contacts.getPhotoForId(contactId);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function addContact(contact: Partial<Contact>): Promise<Contact> {
|
|
29
|
+
return Contacts.addContact(contact);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function openContactForm(contact: Partial<Contact>): Promise<Contact> {
|
|
33
|
+
return Contacts.openContactForm(contact);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function openExistingContact(contact: Contact): Promise<Contact> {
|
|
37
|
+
return Contacts.openExistingContact(contact);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function viewExistingContact(contact: {
|
|
41
|
+
recordID: string;
|
|
42
|
+
}): Promise<Contact | void> {
|
|
43
|
+
return Contacts.viewExistingContact(contact);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function editExistingContact(contact: Contact): Promise<Contact> {
|
|
47
|
+
return Contacts.editExistingContact(contact);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function updateContact(
|
|
51
|
+
contact: Partial<Contact> & { recordID: string }
|
|
52
|
+
): Promise<void> {
|
|
53
|
+
return Contacts.updateContact(contact);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function deleteContact(contact: Contact): Promise<void> {
|
|
57
|
+
return Contacts.deleteContact(contact);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function getContactsMatchingString(str: string): Promise<Contact[]> {
|
|
61
|
+
return Contacts.getContactsMatchingString(str);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function getContactsByPhoneNumber(
|
|
65
|
+
phoneNumber: string
|
|
66
|
+
): Promise<Contact[]> {
|
|
67
|
+
return Contacts.getContactsByPhoneNumber(phoneNumber);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function getContactsByEmailAddress(
|
|
71
|
+
emailAddress: string
|
|
72
|
+
): Promise<Contact[]> {
|
|
73
|
+
return Contacts.getContactsByEmailAddress(emailAddress);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function checkPermission(): Promise<
|
|
77
|
+
"authorized" | "denied" | "undefined"
|
|
78
|
+
> {
|
|
79
|
+
return Contacts.checkPermission();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function requestPermission(): Promise<
|
|
83
|
+
"authorized" | "denied" | "undefined"
|
|
84
|
+
> {
|
|
85
|
+
return Contacts.requestPermission();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function writePhotoToPath(
|
|
89
|
+
contactId: string,
|
|
90
|
+
file: string
|
|
91
|
+
): Promise<boolean> {
|
|
92
|
+
return Contacts.writePhotoToPath(contactId, file);
|
|
93
|
+
}
|
|
94
|
+
export default {
|
|
95
|
+
getAll,
|
|
96
|
+
getAllWithoutPhotos,
|
|
97
|
+
getContactById,
|
|
98
|
+
getCount,
|
|
99
|
+
getPhotoForId,
|
|
100
|
+
addContact,
|
|
101
|
+
openContactForm,
|
|
102
|
+
openExistingContact,
|
|
103
|
+
viewExistingContact,
|
|
104
|
+
editExistingContact,
|
|
105
|
+
updateContact,
|
|
106
|
+
deleteContact,
|
|
107
|
+
getContactsMatchingString,
|
|
108
|
+
getContactsByPhoneNumber,
|
|
109
|
+
getContactsByEmailAddress,
|
|
110
|
+
checkPermission,
|
|
111
|
+
requestPermission,
|
|
112
|
+
writePhotoToPath,
|
|
113
|
+
};
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
|
2
2
|
#import <Contacts/Contacts.h>
|
|
3
3
|
#import <ContactsUI/ContactsUI.h>
|
|
4
|
+
#import <Foundation/Foundation.h>
|
|
4
5
|
|
|
6
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
7
|
+
|
|
8
|
+
#import <RNContactsSpec/RNContactsSpec.h>
|
|
9
|
+
@interface RCTContacts: NSObject <NativeContactsSpec, CNContactViewControllerDelegate>
|
|
10
|
+
|
|
11
|
+
#else
|
|
12
|
+
|
|
13
|
+
#import <React/RCTBridgeModule.h>
|
|
5
14
|
@interface RCTContacts : NSObject <RCTBridgeModule, CNContactViewControllerDelegate>
|
|
6
15
|
|
|
16
|
+
#endif
|
|
17
|
+
|
|
7
18
|
@end
|
|
19
|
+
|