从内部app订阅日历

时间:2013-10-17 07:54:39

标签: ios objective-c ios7 eventkit ekeventkit

我想为我的应用添加功能,以便用户订阅在线日历。 我以前通过打开日历的URL来完成此操作,这会导致iOS询问用户是否要订阅此日历。 这样做的方式在完成后不会给我通知,并且提供糟糕的用户体验。

有更好的方法吗? 我正在研究EventKit和EKCalendarTypeSubscription,但我无法找到我需要的信息。

我是否可以使用EventKit让用户在我的ftp服务器上订阅.ics-calendar并知道用户是否已订阅此日历?

1 个答案:

答案 0 :(得分:4)

您可以使用openURL方法并收听EKEventStoreChangedNotification通知。

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"]];

当用户单击UIAlertView中的“订阅”按钮时,将调用storedChanged:

要检查用户之前是否订阅了日历,请检查calendars上的EKEventStore媒体资源。

相关问题