Skip to content

Commit 18bb60a

Browse files
authored
Fix macOS sample (#69)
1 parent 486dc94 commit 18bb60a

File tree

3 files changed

+51
-29
lines changed

3 files changed

+51
-29
lines changed

samples/Plugin.Maui.CalendarStore.Sample/CalendarsPage.xaml.cs

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,72 @@ public CalendarsPage(ICalendarStore calendarStore)
2121

2222
async void LoadCalendars_Clicked(object sender, EventArgs e)
2323
{
24-
await LoadCalendars();
24+
try
25+
{
26+
await LoadCalendars();
27+
}
28+
catch (Exception ex)
29+
{
30+
await DisplayAlert("Error", ex.Message, "OK");
31+
}
32+
2533
}
2634

2735
async void CreateCalendar_Clicked(object sender, EventArgs e)
2836
{
29-
var createResult = await DisplayPromptAsync("Create Calendar",
30-
"What do you want to name the calendar?");
31-
32-
if (string.IsNullOrWhiteSpace(createResult))
37+
try
3338
{
34-
return;
35-
}
39+
var createResult = await DisplayPromptAsync("Create Calendar",
40+
"What do you want to name the calendar?");
41+
42+
if (string.IsNullOrWhiteSpace(createResult))
43+
{
44+
return;
45+
}
3646

37-
await calendarStore.CreateCalendar(createResult);
47+
await calendarStore.CreateCalendar(createResult);
3848

39-
await LoadCalendars();
49+
await LoadCalendars();
4050

41-
await DisplayAlert("Calendar Created",
42-
$"Calendar \"{createResult}\" created successfully.", "OK");
51+
await DisplayAlert("Calendar Created",
52+
$"Calendar \"{createResult}\" created successfully.", "OK");
53+
}
54+
catch (Exception ex)
55+
{
56+
await DisplayAlert("Error", ex.Message, "OK");
57+
}
4358
}
4459

4560
async void Update_Clicked(object sender, EventArgs e)
4661
{
47-
if ((sender as BindableObject)?.
48-
BindingContext is not Calendar calendarToUpdate)
62+
try
4963
{
50-
await DisplayAlert("Error", "Could not determine calendar to update.", "OK");
51-
return;
52-
}
64+
if ((sender as BindableObject)?.
65+
BindingContext is not Calendar calendarToUpdate)
66+
{
67+
await DisplayAlert("Error", "Could not determine calendar to update.", "OK");
68+
return;
69+
}
5370

54-
var updateResult = await DisplayPromptAsync("Update Calendar",
55-
"Enter the updated calendar name:", placeholder: calendarToUpdate.Name);
71+
var updateResult = await DisplayPromptAsync("Update Calendar",
72+
"Enter the updated calendar name:", placeholder: calendarToUpdate.Name);
5673

57-
if (string.IsNullOrWhiteSpace(updateResult))
58-
{
59-
return;
60-
}
74+
if (string.IsNullOrWhiteSpace(updateResult))
75+
{
76+
return;
77+
}
6178

62-
await calendarStore.UpdateCalendar(calendarToUpdate.Id, updateResult);
79+
await calendarStore.UpdateCalendar(calendarToUpdate.Id, updateResult);
6380

64-
await LoadCalendars();
81+
await LoadCalendars();
6582

66-
await DisplayAlert("Calendar Updated",
67-
$"Calendar \"{updateResult}\" updated successfully.", "OK");
83+
await DisplayAlert("Calendar Updated",
84+
$"Calendar \"{updateResult}\" updated successfully.", "OK");
85+
}
86+
catch (Exception ex)
87+
{
88+
await DisplayAlert("Error", ex.Message, "OK");
89+
}
6890
}
6991

7092
async void Delete_Clicked(object sender, EventArgs e)

samples/Plugin.Maui.CalendarStore.Sample/Platforms/MacCatalyst/Entitlements.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<dict>
55
<key>com.apple.security.app-sandbox</key>
66
<true/>
7-
<key>com.apple.security.personal-information.calendar</key>
7+
<key>com.apple.security.personal-information.calendars</key>
88
<true/>
99
</dict>
1010
</plist>

samples/Plugin.Maui.CalendarStore.Sample/Platforms/MacCatalyst/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</array>
2727
<key>XSAppIconAssets</key>
2828
<string>Assets.xcassets/appicon.appiconset</string>
29-
<key>NSCalendarsUsageDescription</key>
30-
<string>This app wants to read your calendar data.</string>
29+
<key>NSCalendarsFullAccessUsageDescription</key>
30+
<string>This app wants to read and write your calendar data.</string>
3131
</dict>
3232
</plist>

0 commit comments

Comments
 (0)