views:

9398

answers:

10

Is there any way to add iCal event to the iPhone Calendar from the custom App?

+1  A: 

Currenctly there is no API for manipulating calendars from your own application on the phone. There is an API for the address book.

Anyone know if this is going to be addressed?

Tony Lambert
https://developer.apple.com/bugreporter/ is the best answer )
Stream
A: 

I guess your app could talk to a server which modified a calendar that got published back to the phone using Mobile ME !!!

Rather you than me.

Tony Lambert
+7  A: 

Yes there still is no API for this (2.1). But it seemed like at WWDC a lot of people were already interested in the functionality (including myself) and the recommendation was to go to the below site and create a feature request for this. If there is enough of an interest, they might end up moving the ICal.framework to the public SDK.

https://developer.apple.com/bugreporter/

keremk
A: 

Does anyone know if 3.0 included the ability to launch the calendar application to the new event screen with select properties pre-populated (i.e. the date and a title)? This would be very useful as a button in a custom application I'm building.

A: 

If you use Google Calendar to sync you IPhone calendar you can use the Google Data Calendar API to add an event to Google Calendar and this is pushed to you IPhone calendar

clearbrian
A: 

The Google idea is a nice one, but has problems.

I can successfully open a Google calendar event screen - but only on the main desktop version, and it doesn't display properly on iPhone Safari. The Google mobile calendar, which does display properly on Safari, doesn't seem to work with the API to add events.

For the moment, I can't see a good way out of this one.

xgretsch
+3  A: 

Calendar access is being added in iPhone OS 4.0:

Calendar Access
Apps can now create and edit events directly in the Calendar app with Event Kit.
Create recurring events, set up start and end times and assign them to any calendar on the device.

Chris S
+11  A: 

Hi. You can do this using the Event Kit framework in OS 4.0.

Right click on the FrameWorks group in the Groups and Files Navigator on the left of the window. Select 'Add' then 'Existing FrameWorks' then 'EventKit.Framework'.

Then you should be able to add events with code like this:

//
//  EventTestViewController.m
//  EventTest
//
//  Created by Some Person on 5/07/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "EventTestViewController.h"
#import <EventKit/EventKit.h>

@implementation EventTestViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    EKEventStore *eventStore = [[EKEventStore alloc] init];

    EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
    event.title     = @"EVENT TITLE";

    event.startDate = [[NSDate alloc] init];
    event.endDate   = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];

    [event setCalendar:[eventStore defaultCalendarForNewEvents]];
    NSError *err;
    [eventStore saveEvent:event span:EKSpanThisEvent error:&err];       
}



- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
Tristan
Finally. Thank you all :)
Stream
Thanks for posting this. Just a reminder to all who read this: take care to watch for memory leaks. There are a couple in this code sample. Also, best practices would dictate that you check the value of 'err' after saveEvent:span:error and handle things accordingly.
D Carney
Do you know how to add recurrence event? like an event for every monday?
Jay Vachhani
A: 

great.

again, doesn't work on earlier iPhone OS?!

Daveice
A: 

i want to make an app that can synchronize google cal and calendar in iphone..i want to do it through coding...is it possible..?

one method -- i have an app that can fetch events from google cal and show in table view...i can add these events to iphone 's native calendar..can i try these code in iphone simulator...

other method is their any code that can directly store the google cal's events in iphone native cal..?

Kuldeep Sidhu
You want to ask a question not post an answer.
toxaq