@@ -38,25 +38,38 @@ public class CalendarPermission: Permission {
3838
3939 open override var kind : Permission . Kind { . calendar }
4040 open var usageDescriptionKey : String ? { " NSCalendarsUsageDescription " }
41+ open var usageFullAccessDescriptionKey : String ? { " NSCalendarsFullAccessUsageDescription " }
42+ open var usageWriteOnlyAccessDescriptionKey : String ? { " NSCalendarsWriteOnlyAccessUsageDescription " }
4143
4244 public override var status : Permission . Status {
4345 switch EKEventStore . authorizationStatus ( for: EKEntityType . event) {
4446 case . authorized: return . authorized
4547 case . denied: return . denied
48+ case . fullAccess: return . authorized
4649 case . notDetermined: return . notDetermined
4750 case . restricted: return . denied
51+ case . writeOnly: return . authorized
4852 @unknown default : return . denied
4953 }
5054 }
5155
5256 public override func request( completion: @escaping ( ) -> Void ) {
57+
5358 let eventStore = EKEventStore ( )
54- eventStore. requestAccess ( to: EKEntityType . event, completion: {
55- ( accessGranted: Bool , error: Error ? ) in
56- DispatchQueue . main. async {
57- completion ( )
59+
60+ if #available( iOS 17 . 0 , * ) {
61+ eventStore. requestFullAccessToEvents { ( accessGranted: Bool , error: Error ? ) in
62+ DispatchQueue . main. async {
63+ completion ( )
64+ }
5865 }
59- } )
66+ } else {
67+ eventStore. requestAccess ( to: EKEntityType . event) { ( accessGranted: Bool , error: Error ? ) in
68+ DispatchQueue . main. async {
69+ completion ( )
70+ }
71+ }
72+ }
6073 }
6174}
6275#endif
0 commit comments