Events not adding in Iphone 5 default calendar - iphone

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?

Related

NSDateFormatter dateFromString returns NULL except on iPhone 5

I've read all the answers on getting this to work but I still cannot get it to work on phones below iPhone 5. On iPhone 5, all is well. On iPhone 4 and 3GS, I get NULL. No matter what I change, it does not seem to work. My 3GS is running IOS 6.1.3. I'm not sure what the 4's are running (as no one that has one is in yet). My 5 is running 7.1.1. I'm assuming this is where the issue is, but cannot find that being said anywhere. However, if this is the case, is there another way I could do this if date is null? My code is below.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:#"GMT"]];
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:#"en_US_POSIX"]];
[dateFormatter setDateFormat:#"yyyy-MM-dd'T'HH:mm:ssZZZ"];
NSDate *date = [dateFormatter dateFromString:#"2014-06-06T11:30:09-0400"];
Thanks for any help.
Ok, so after I finally posted this after looking forever, I did finally find the fix. I simply needed to add 2 more Z's. My final format is yyyy-MM-dd'T'HH:mm:ssZZZZZ.

iOS7 device get restarted when using 'saveEvent:span:commit:error:' method

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.

How to invalidate my app after a certain amount of time in iPhone using provisioning profile

I want my iPhone app to be valid only for a particular time period. This has to be done by provisioning profile and not through the App Store. Please give me some suggestions.
Create a NSDate that represents the end time of your app preview. Then compare it to the current time and if the result is grater then you should exit the app. Although it is better to display a message to the user that the preview period expired as apple does not provide a straight forward way to exit the app.
NSString *dateString = #"25-Dec-10";
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
dateFormatter.dateFormat = #"dd-MMM-yy";
NSDate *endDate = [dateFormatter dateFromString:dateString];
if([[NSDate date] timeIntervalSinceDate:endDate] >= 0){
//Display message to the user
}

How to add Events in iPhone calendar application using our iphone application.

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

How to check custom event added in the iPhone Calendar using iphone simulator

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