Skip to content

Commit

Permalink
Re-add back in legacy calendar permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
edgiardina committed Mar 1, 2024
1 parent 7c0d5e4 commit d260eec
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Platforms/iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<string>This app will allow you to add an IFPA sanctioned tournament from the app to your local device&apos;s calendar</string>
<key>NSCalendarsWriteOnlyAccessUsageDescription</key>
<string>This app will allow you to add an IFPA sanctioned tournament from the app to your local device&apos;s calendar</string>
<key>NSCalendarsUsageDescription</key>
<string>This app will allow you to add an IFPA sanctioned tournament from the app to your local device&apos;s calendar</string>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.shiny.job</string>
Expand Down
26 changes: 24 additions & 2 deletions Platforms/iOS/ReminderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Foundation;
using Ifpa.Interfaces;
using Ifpa.ViewModels;
using UIKit;

namespace Ifpa.Services
{
Expand All @@ -11,7 +12,18 @@ public class ReminderService : IReminderService

public async Task<bool> CreateReminder(CalendarDetailViewModel calendarDetail, string calendarIdentifier)
{
var granted = await eventStore.RequestWriteOnlyAccessToEventsAsync();
Tuple<bool, NSError> granted;

// if ios 17, use RequestWriteOnlyAccessToEventsAsync, otherwise use RequestAccessAsync
if (UIDevice.CurrentDevice.CheckSystemVersion(17, 0))
{
granted = await eventStore.RequestWriteOnlyAccessToEventsAsync();
}
else
{
granted = await eventStore.RequestAccessAsync(EKEntityType.Event);
}

if (granted.Item1)
{
var calendars = eventStore.GetCalendars(EKEntityType.Event);
Expand All @@ -38,7 +50,17 @@ public async Task<bool> CreateReminder(CalendarDetailViewModel calendarDetail, s

public async Task<IEnumerable<string>> GetCalendarList()
{
var granted = await eventStore.RequestFullAccessToEventsAsync();
Tuple<bool, NSError> granted;

if (UIDevice.CurrentDevice.CheckSystemVersion(17, 0))
{
granted = await eventStore.RequestFullAccessToEventsAsync();
}
else
{
granted = await eventStore.RequestAccessAsync(EKEntityType.Event);
}

if (granted.Item1)
{
var calendars = eventStore.GetCalendars(EKEntityType.Event)
Expand Down

0 comments on commit d260eec

Please sign in to comment.