Open “Event Details” in calendar app with specific event id

半城伤御伤魂 提交于 2019-12-04 01:01:17

问题


I am trying to open calendar with specific event, I have added events programmatically and all the IDs of these event are persistent.

This is how i add event

-(IBAction)addEvent:(id)sender{
    EKEventStore *store = [[EKEventStore alloc]init];
    [store requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
        if (!granted) { return; }
        EKEvent *event = [EKEvent eventWithEventStore:store];
        event.title = @"Demo Title";
        NSDateComponents *comps=[[NSDateComponents alloc]init];
        [comps setDay:4];
        [comps setMonth:10];
        [comps setYear:2016];
        [comps setHour:12];
        [comps setMinute:1];

        NSDate *date=[[[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian] dateFromComponents:comps];
        _date=date;
        event.startDate = date;
        event.endDate=date;
        event.notes=@"This is event description";

        EKAlarm *alarm=[EKAlarm alarmWithAbsoluteDate:date];
        [event addAlarm:alarm];
        event.calendar = [store defaultCalendarForNewEvents];

        NSError *err=nil;
        [store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
    }];
}

The event is added successfully and i'm also able to open calendar app but the thing is i can't navigate inside the event detail in calendar

here is how i open calendar

-(IBAction)openCalender:(id)sender{
    NSInteger interval = [_date timeIntervalSinceReferenceDate];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"calshow:%ld?eventid=%@", (long)interval,_eventID]];
    NSLog(@"%@",url);
    [[UIApplication sharedApplication] openURL:url];
}

What i want is in below screenshot

What i'm getting is

any idea?


回答1:


To answer my own question, this isn't possible with any of public API

I searched over a year but this is not possible with any public API, but i guess there might be some private API to do this (and probably doing that will get our app rejected).

Widget of calendar app is doing the same what i want to do but it's Apple's API wont allow us to use it. lol




回答2:


I really don't think there's a way to do this. Even when creating a new calendar event from the default Mail app opens the calendar day view. If this functionality was possible I'm sure they would have at least implemented it in the default mail app.



来源:https://stackoverflow.com/questions/39846024/open-event-details-in-calendar-app-with-specific-event-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!