react-native-contacts 8.0.0 → 8.0.2
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/README.md +3 -0
- package/index.ts +3 -7
- package/ios/RCTContacts/RCTContacts.h +1 -1
- package/ios/RCTContacts/RCTContacts.mm +9 -4
- package/package.json +1 -1
- package/react-native-contacts.podspec +1 -0
- package/src/NativeContacts.ts +3 -3
- package/type.ts +2 -0
package/.tool-versions
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
nodejs
|
|
1
|
+
nodejs lts
|
package/README.md
CHANGED
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NativeModules } from "react-native";
|
|
2
2
|
import NativeContacts from "./src/NativeContacts";
|
|
3
|
-
import { Contact } from "./type";
|
|
3
|
+
import { Contact, PermissionType } from "./type";
|
|
4
4
|
|
|
5
5
|
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
6
6
|
const Contacts = isTurboModuleEnabled ? NativeContacts : NativeModules.Contacts;
|
|
@@ -73,15 +73,11 @@ async function getContactsByEmailAddress(
|
|
|
73
73
|
return Contacts.getContactsByEmailAddress(emailAddress);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
async function checkPermission(): Promise<
|
|
77
|
-
"authorized" | "denied" | "undefined"
|
|
78
|
-
> {
|
|
76
|
+
async function checkPermission(): Promise<PermissionType> {
|
|
79
77
|
return Contacts.checkPermission();
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
async function requestPermission(): Promise<
|
|
83
|
-
"authorized" | "denied" | "undefined"
|
|
84
|
-
> {
|
|
80
|
+
async function requestPermission(): Promise<PermissionType> {
|
|
85
81
|
return Contacts.requestPermission();
|
|
86
82
|
}
|
|
87
83
|
|
|
@@ -44,6 +44,7 @@ RCT_EXPORT_MODULE();
|
|
|
44
44
|
return @{
|
|
45
45
|
@"PERMISSION_DENIED": @"denied",
|
|
46
46
|
@"PERMISSION_AUTHORIZED": @"authorized",
|
|
47
|
+
@"PERMISSION_LIMITED": @"limited",
|
|
47
48
|
@"PERMISSION_UNDEFINED": @"undefined"
|
|
48
49
|
};
|
|
49
50
|
}
|
|
@@ -63,6 +64,8 @@ RCT_EXPORT_METHOD(checkPermission:(RCTPromiseResolveBlock) resolve
|
|
|
63
64
|
resolve(@"denied");
|
|
64
65
|
} else if (authStatus == CNAuthorizationStatusAuthorized){
|
|
65
66
|
resolve(@"authorized");
|
|
67
|
+
} else if (authStatus == CNAuthorizationStatusLimited) {
|
|
68
|
+
resolve(@"limited");
|
|
66
69
|
} else {
|
|
67
70
|
resolve(@"undefined");
|
|
68
71
|
}
|
|
@@ -565,7 +568,7 @@ RCT_EXPORT_METHOD(getPhotoForId:(nonnull NSString *)recordID resolver:(RCTPromis
|
|
|
565
568
|
}
|
|
566
569
|
}];
|
|
567
570
|
}
|
|
568
|
-
else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized)
|
|
571
|
+
else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized || [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusLimited)
|
|
569
572
|
{
|
|
570
573
|
resolve([self getFilePathForThumbnailImage:recordID addressBook:contactStore]);
|
|
571
574
|
}
|
|
@@ -603,7 +606,7 @@ RCT_EXPORT_METHOD(getContactById:(nonnull NSString *)recordID resolver:(RCTPromi
|
|
|
603
606
|
}
|
|
604
607
|
}];
|
|
605
608
|
}
|
|
606
|
-
else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized)
|
|
609
|
+
else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized || [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusLimited))
|
|
607
610
|
{
|
|
608
611
|
resolve([self getContact:recordID addressBook:contactStore withThumbnails:false]);
|
|
609
612
|
}
|
|
@@ -1285,6 +1288,8 @@ RCT_EXPORT_METHOD(writePhotoToPath:(nonnull NSString *)path resolver:(RCTPromise
|
|
|
1285
1288
|
resolve(@"denied");
|
|
1286
1289
|
} else if (authStatus == CNAuthorizationStatusAuthorized){
|
|
1287
1290
|
resolve(@"authorized");
|
|
1291
|
+
} else if (authStatus == CNAuthorizationStatusLimited) {
|
|
1292
|
+
resolve(@"limited");
|
|
1288
1293
|
} else {
|
|
1289
1294
|
resolve(@"undefined");
|
|
1290
1295
|
}
|
|
@@ -1435,7 +1440,7 @@ RCT_EXPORT_METHOD(writePhotoToPath:(nonnull NSString *)path resolver:(RCTPromise
|
|
|
1435
1440
|
}
|
|
1436
1441
|
}];
|
|
1437
1442
|
}
|
|
1438
|
-
else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized)
|
|
1443
|
+
else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized || [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusLimited))
|
|
1439
1444
|
{
|
|
1440
1445
|
resolve([self getContact:recordID addressBook:contactStore withThumbnails:false]);
|
|
1441
1446
|
}
|
|
@@ -1485,7 +1490,7 @@ RCT_EXPORT_METHOD(writePhotoToPath:(nonnull NSString *)path resolver:(RCTPromise
|
|
|
1485
1490
|
}
|
|
1486
1491
|
}];
|
|
1487
1492
|
}
|
|
1488
|
-
else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized)
|
|
1493
|
+
else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized || [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusLimited))
|
|
1489
1494
|
{
|
|
1490
1495
|
resolve([self getFilePathForThumbnailImage:recordID addressBook:contactStore]);
|
|
1491
1496
|
}
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.platform = :ios, "12.0"
|
|
18
18
|
s.source = { :git => "https://github.com/rt2zz/react-native-contacts.git", :tag => "v#{s.version}" }
|
|
19
19
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
20
|
+
s.frameworks = 'Contacts', 'ContactsUI', 'Photos'
|
|
20
21
|
|
|
21
22
|
s.dependency 'React-Core'
|
|
22
23
|
|
package/src/NativeContacts.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
|
|
2
2
|
import { TurboModuleRegistry } from "react-native";
|
|
3
|
-
import { Contact } from "../type";
|
|
3
|
+
import { Contact, PermissionType } from "../type";
|
|
4
4
|
|
|
5
5
|
export interface Spec extends TurboModule {
|
|
6
6
|
getAll: () => Promise<any>;
|
|
@@ -18,8 +18,8 @@ export interface Spec extends TurboModule {
|
|
|
18
18
|
getContactsMatchingString: (str: string) => Promise<Contact[]>;
|
|
19
19
|
getContactsByPhoneNumber: (phoneNumber: string) => Promise<Contact[]>;
|
|
20
20
|
getContactsByEmailAddress: (emailAddress: string) => Promise<Contact[]>;
|
|
21
|
-
checkPermission: () => Promise<
|
|
22
|
-
requestPermission: () => Promise<
|
|
21
|
+
checkPermission: () => Promise<PermissionType>;
|
|
22
|
+
requestPermission: () => Promise<PermissionType>;
|
|
23
23
|
writePhotoToPath: (contactId: string, file: string) => Promise<boolean>;
|
|
24
24
|
iosEnableNotesUsage: (enabled: boolean) => void;
|
|
25
25
|
}
|