I am developing an application which copies appointment records from my app to devices native calendar. I am using the following code to do that.
NSString *eventIde = nil;
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKCalendar *calendarDef = [eventStore defaultCalendarForNewEvents];
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
[event setCalendar:calendarDef];
//set values to this event. like title, notes, startDate, endDate, location
NSError *err1 = nil;
BOOL isStoredd = [eventStore saveEvent:event span:EKSpanThisEvent commit:YES error:&err1];
if(isStoredd){
eventIde = [NSString stringWithString:event.eventIdentifier];
}
Here I am creating EKEvents for each appointment in my app, sets appropreate values, and saves the event to event store. This is done simultaniously for about 200 records.It was working fine in iOS6, when i updated the ipad to iOS7 it causes the device to restart. I tried the same with record count 50, then also same issue occured.
Sometimes it shows an over memorry problem, sometimes shows 'Terminating in response to SpringBoard's termination'. I need the eventIdentifier to enter into my database for further use. But everytime this issue occures and device restarts.
Can anybody help me with this problem? What is special with iOS7 eventstore?
Or please advice any solution to overcome this issue.
Thanks
The first section of the Calendar and Reminders programming guide on Apple.com has your answer.
You do not allocate the store multiple times unless you have more than one Calendar, like FB events.
I highly recommend Apple's guides, they're easier than 3rd party books oftentimes.
Related
I want to add reminder functionality in my iphone app, I came to know that I need to use local notification but I don't want to use it.
So is there any way to fulfill my need ??
UILocalNotification is a nice thing but if you don't want to use it you can make use of EventKit that gives you access to device's reminders.
Create EventStore object with reminder type.
EKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskReminder];
Get access from user.
[store requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
// handle access here }];
use this function to create reminders
+ (EKReminder *)reminderWithEventStore:(EKEventStore *)eventStore
Refer documentation for more details .
There is an another way, other than using the local notification, see my answer posted hear in this u set an event in the calendar and set the repeat settings by setting alarm.
Hope this helps you.
If you don't want to use UILocal notification use EKEventStore for adding reminders in iPhone Calendar. You can add your alarm, events etc in iPhone Calendar.
But remember it supports only iOS 6.0 or later. you cannot change in iPhone calendar in lower iOS6.0 version
Follow these links:
Link-1
Link-2
In my app i have to add the event to Iphone default calendar.I wrote the code as follows
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event1 = [EKEvent eventWithEventStore:eventStore];
event1.notes=descriptionStr;
event1.startDate =edate;
event1.endDate=fdate;
[event1 setTimeZone:[NSTimeZone systemTimeZone]];
[event1 setCalendar:[eventStore defaultCalendarForNewEvents]];
Problem is with Iphone5. For 4S and previous versions event is adding perfectly. please guide me.Thank you.
According to the Apple documentation of EKEventStoreClassRef:
On iOS 5 and later, initialize an event store object with the default init method. On iOS 6 and later, you must request access to an entity type after the event store is initialized with requestAccessToEntityType:completion: for data to return.
Does it work on 4S with iOS 6 installed?
How to add Event in iPhone Calendar. I just want to add events in iPhone calendar using my application and wants to set pushnotification for perticuler event. Please help me out on this. Thank you.
To create an Event programmatically, you would use EventKit, more specifically the provided EKEventEditViewController. See the Apple documentation for an explanation and sample code.
In iOS 4.0+, you would also be able to access that controller without writing any EventKit code. To do that, use a UITextView configured with dataDetectorTypes = UIDataDetectorTypeCalendarEvent. The UITextView will automatically convert strings representing formatted dates, days of the week, etc. - to clickable URLs that handle the creation of events.
Please refer to the Apple iOS documentation for the rest of your question. If there is anything specific that doesn't work in your case, please post some code, show us what you have tried already, etc.
you can use this code
EKEventStore *es = [[EKEventStore alloc] init];
EKEventEditViewController *controller = [[EKEventEditViewController alloc] init];
controller.eventStore = es;
controller.editViewDelegate = self;
[self presentModalViewController:controller animated:YES];
[controller release];
I am setting a reminder in my app. I have added a custom event using EKEvent to iCal. Now when I retrieve events from iCal I get all the events present on that day. Is there any way to get/retrieve events added through my app only, I tried eventIdentifier property of EKEvent but it is a readonly property.
Can anybody help???
You could loop through all of the calendar events that match a specific date but that is not the preferred method. Each event is created with a unique eventIdentifier property. When you save the event you can copy the eventIdentifier and next time you want to modify that specific event you can use the EKEventStore eventWithIdentifier Method to load your Event.
A sample might look like this
EKEventStore *eventStore = [[EKEventStore alloc] init];
NSError *err;
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
//modify all the event properties you would like then save
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
self.calendarEventID = event.eventIdentifier;
[eventStore release];
Later if you want to retrieve the saved event from the previous code you could do the following
//self.calendarEventID is a NSString property declared in the .h file and synthesized in .m
EKEvent *myEvent = [eventStore eventWithIdentifier:self.calendarEventID];
Kludge:
I had a similar problem with an AppleScript I made for setting iCal alarms; I wanted to be able to identify and delete the events my script had made on the next pass.
I couldn't find any tag-like properties for iCal events, so I ended up using the location property, which is a string; I set it to " " and searched for that. (Caveat: The alarm message includes the location at the end, surrounded by parens, so this glops things up a bit.)
If you need the location property for other purposes in your app, you still might be able to add some identifying character sequence. Or maybe you can use some other property you don't otherwise need.
I have founded the code, Programmatically added custom event in the iPhone Calendar,using event kit framework.
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];
I used the above code and i want to check whether these event is added in iphone calendar or not.I have latest sdk 4.0 version, but my device is first generation of ipod device.so i can't launch my application in ipod (due to eventkit framework not supported).Is this possible to check this in iphone simulator ? Or anyother thoughts to check this custom event added in icalendar ?
Please help me . Thanks in advance.......
Arrange a device to test it, else have faith in the developer documentation and simply follow the code sample given there and you should sail smoothly. :)
How can I programmatically create an iCal event in the default calendar?
This question covers how to add an event and then check for existence.
But yes, you will need to test on a device that is running a version of the OS that supports EventKit. Otherwise you cannot ensure the on-device behavior of your app.
While there is no calendar app in the simulator the entries are stored in a sqlite database in $HOME/Library/Application Support/iPhone Simulator//Library/Calendar/Calendar.sqlitedb
Calendar Events are stored in several tables but mainly in a table called CalendarItem which can be opened with a sqlite viewer.
If you need a very easy sql lite viewer the FireFox plugin SQLite Manager works like a champ.
Hope this helps.
Rich