Pergunta

I want to add functionality to my app to enable users to subscribe to an online calendar. I have previously done this by opening the url to the calendar which causes iOS to ask the user if he wants to subscribe to this calendar. This way of doing it gives me no notification when done, and provides a bad user experience.

Is there a better way? I am looking into EventKit and EKCalendarTypeSubscription, but I am unable to find the information I need.

Can I, using EventKit, have the user subscribe to an .ics-calendar on my ftp server and know whether the user is already subscribing to this calendar or not?

Foi útil?

Solução

You could use the openURL approach and listen for the EKEventStoreChangedNotification notification.

self.eventStore = [[EKEventStore alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(storeChanged:)
                                             name:EKEventStoreChangedNotification object:self.eventStore];
// Prompt the to subscribe to the calendar
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://domain/path/to/cal.ics"]];

When the user clicks the Subscribe button in the UIAlertView, storedChanged: will be called.

To check whether a user has previously subscribed to the calendar or not, check the calendars property on EKEventStore.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top