简体   繁体   中英

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

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM