Skip to content

Commit f46333d

Browse files
committed
feat: add reminder status support
1 parent 31ba9f5 commit f46333d

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ This native Node.js module allows you to manage an app's access to:
99
* Contacts
1010
* Full Disk Access
1111
* Calendar
12+
* Reminders
1213
* Photos
1314

1415
## API
1516

1617
## `permissions.getAuthStatus(type)`
1718

18-
* `type` - The type of system component to which you are requesting access. Can be one of `contacts`, `full-disk-access`, `photos`, or `calendar`.
19+
* `type` - The type of system component to which you are requesting access. Can be one of 'contacts', 'full-disk-access', 'photos', 'reminders', or 'calendar'.
1920

2021
Returns `String` - Can be one of 'Not Determined', 'Denied', 'Authorized', or 'Restricted'.
2122

@@ -27,4 +28,4 @@ Return Value Descriptions:
2728
* 'Denied' - The user explicitly denied access to `type` data for the application.
2829
* 'Authorized' - The application is authorized to access `type` data.
2930

30-
**Note:** Access to `contacts` will always return a status of 'Authorized' prior to macOS 10.13 High Sierra, as access to contacts was unilaterally allowed until that version.
31+
**Note:** Access to 'contacts' will always return a status of 'Authorized' prior to macOS 10.13 High Sierra, as access to contacts was unilaterally allowed until that version.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const permissions = require('bindings')('permissions.node')
22

33
function getAuthStatus(type) {
4-
const validTypes = ['contacts', 'calendar', 'photos', 'full-disk-access']
4+
const validTypes = ['contacts', 'calendar', 'reminders', 'photos', 'full-disk-access']
55
if (!validTypes.includes(type)) {
66
throw new TypeError(`${type} is not a valid type`)
77
}

permissions.mm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
}
4444

4545
// Returns a status indicating whether or not the user has authorized Calendar access
46-
std::string CalendarAuthStatus() {
46+
std::string EventAuthStatus(std::string type) {
4747
std::string auth_status = "Not Determined";
4848

49-
EKEntityType entityType = EKEntityTypeEvent;
49+
EKEntityType entityType = (type == "calendar") ? EKEntityTypeEvent : EKEntityTypeReminder;
5050
EKAuthorizationStatus status = [EKEventStore authorizationStatusForEntityType:entityType];
5151

5252
if (status == EKAuthorizationStatusAuthorized)
@@ -113,9 +113,11 @@
113113
if (type == "contacts") {
114114
auth_status = ContactAuthStatus();
115115
} else if (type == "calendar") {
116-
auth_status = CalendarAuthStatus();
116+
auth_status = EventAuthStatus("calendar");
117117
} else if (type == "photos") {
118118
auth_status = PhotosAuthStatus();
119+
} else if (type == "reminders") {
120+
auth_status = EventAuthStatus("reminders");
119121
} else if (type == "full-disk-access") {
120122
auth_status = FDAAuthStatus();
121123
}

test/module.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('node-mac-permissions', () => {
1212
})
1313

1414
it('should return a string', () => {
15-
const types = ['contacts', 'calendar', 'photos', 'full-disk-access']
15+
const types = ['contacts', 'calendar', 'reminders', 'photos', 'full-disk-access']
1616
const statuses = ['Not Determined', 'Denied', 'Authorized', 'Restricted']
1717
for (const type of types) {
1818
const status = getAuthStatus(type)

0 commit comments

Comments
 (0)