fix(ios): tighten calendar scope and avoid headless contacts prompts

This commit is contained in:
Eulices Lopez 2026-03-20 07:25:46 -04:00
parent 184a590a3d
commit 3540c35cc2
4 changed files with 22 additions and 6 deletions

View File

@ -46,7 +46,7 @@ final class CalendarService: CalendarServicing {
let status = EKEventStore.authorizationStatus(for: .event)
let authorized: Bool
if status == .notDetermined {
authorized = await Self.requestEventAccess(store: store)
authorized = await Self.requestWriteOnlyEventAccess(store: store)
} else {
authorized = EventKitAuthorization.allowsWrite(status: status)
}
@ -121,6 +121,22 @@ final class CalendarService: CalendarServicing {
}
}
private static func requestWriteOnlyEventAccess(store: EKEventStore) async -> Bool {
if #available(iOS 17.0, *) {
return await withCheckedContinuation { continuation in
store.requestWriteOnlyAccessToEvents { granted, _ in
continuation.resume(returning: granted)
}
}
}
return await withCheckedContinuation { continuation in
store.requestAccess(to: .event) { granted, _ in
continuation.resume(returning: granted)
}
}
}
private static func resolveCalendar(
store: EKEventStore,
calendarId: String?,

View File

@ -103,11 +103,8 @@ final class ContactsService: ContactsServicing {
case .authorized, .limited:
return true
case .notDetermined:
return await withCheckedContinuation { continuation in
store.requestAccess(for: .contacts) { granted, _ in
continuation.resume(returning: granted)
}
}
// Avoid prompting during node.invoke; headless/unattended flows should fail fast.
return false
case .restricted, .denied:
return false
@unknown default:

View File

@ -54,6 +54,8 @@
<string>OpenClaw uses your calendars to show events and scheduling context when you enable calendar access.</string>
<key>NSCalendarsFullAccessUsageDescription</key>
<string>OpenClaw uses your calendars to show events and scheduling context when you enable calendar access.</string>
<key>NSCalendarsWriteOnlyAccessUsageDescription</key>
<string>OpenClaw uses your calendars to add events when you enable calendar access.</string>
<key>NSContactsUsageDescription</key>
<string>OpenClaw uses your contacts so you can search and reference people while using the assistant.</string>
<key>NSLocalNetworkUsageDescription</key>

View File

@ -136,6 +136,7 @@ targets:
NSCameraUsageDescription: OpenClaw can capture photos or short video clips when requested via the gateway.
NSCalendarsUsageDescription: OpenClaw uses your calendars to show events and scheduling context when you enable calendar access.
NSCalendarsFullAccessUsageDescription: OpenClaw uses your calendars to show events and scheduling context when you enable calendar access.
NSCalendarsWriteOnlyAccessUsageDescription: OpenClaw uses your calendars to add events when you enable calendar access.
NSContactsUsageDescription: OpenClaw uses your contacts so you can search and reference people while using the assistant.
NSLocationWhenInUseUsageDescription: OpenClaw uses your location when you allow location sharing.
NSLocationAlwaysAndWhenInUseUsageDescription: OpenClaw can share your location in the background when you enable Always.