I have built an app for week numbers, and I have made an ics file with week numbers in, but how can I open it with Objective-C so it will subscribe into calender?
I can't figure out how I can do this. Are there any frameworks I can use, or what?
I have tried:
NSString *ical = [NSString stringWithContentsOfURL:
[NSURL URLWithString:#"http://xxxxxxxxxxx.xx/apps-iphone/weeknumber/ical/ical.ics"] encoding:NSUTF8StringEncoding error:NULL];
but I can open it with that.
It needs to look like this:
Hope you understand me. :)
I'm pretending that you have the .ics file inside your app, right? And with this .ics file you want to open the Safari and have the alert?
Take a look at EventKit framework. You can integrate your app with the user's calendar. From EventKit's programming guide:
Event Kit not only allows your app to retrieve users’ existing
calendar and reminder data, but it also lets your app create new
events and reminders for any of their calendars. In addition, Event
Kit lets users edit and delete their events and reminders
(collectively known as “calendar items”). More advanced tasks, such as
adding alarms or specifying recurring events, can be achieved with
Event Kit as well. If a change to the Calendar database occurs from
outside of your app, Event Kit is able to detect the change by
notification so your app can act appropriately. Changes made to
calendar items with Event Kit are automatically synced to the
associated calendar (CalDAV, Exchange, and so on).
As an alternative, you can open it using this code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://addressToYourics.ics"]];
But, unfortunately, you can't open bundle files with Safari, so I suggest you to use the EventKit library.
Take a look at another questions:
Is there a calendar control we can use for iPhone apps?
How to programmatically add calendar subscriptions on iOS?
Related
I've got a calendar that has iCalendar standard integration, but I'm not sure how to really get the data from the iCal link and bring it over to the iOS app I'm developing. I'm using JTAppleCalendar, and I've watched his video on how to stream data from a server, but I'm still not quite sure how to get the iCal event data into a form/place that is able to be utilized by the app.
I've already searched around and watched videos but I was unable to find an answer. I've also tried importing the calendar to google calendar for use through that API, but I'm unable to get that working either.
I want to be able to have the calendar remain public and for the user to be able to see the events without having to sign in to anything (like google for example) or have to add the iCal on their own for it to work.
This may be a simple question, but I'm still in the very early stages of learning iOS dev, so sorry about that.
In my app I'm using the EventKit API to access calendars on my device, and display them in my views. When working with network calendars, however, I suspect that EKEventStore will only return some sort of cached/local event list when queried, rather than reloading the calendar and return the actual/most recent contents.
When the native calendar app is launched instead, the app will refresh/reload all calendars, synchronizing any network shared calendars. Going back to my app will now also display the newly synchronized events.
In Addition to this, I found that modifying any events (delete/update) via my app and EventKit / EventKitUI will not sync back to e. g. my Mac's calendar.
To cut the long story short: Is there any way to force synchronization with network shared calendars in EventKit/iOS SDK?
You can use the - (void)refreshSourcesIfNecessary method of an EKEventStore instance to:
... pull new data from remote sources if the local data is out of date.
This would force an update of the local calendar store by fetching the latest remote data. I have a feeling this is the method the native iOS Calendar app is using to prompt an update.
As for the issue with deleted and updated calendar events not syncing to your Mac, are you sure you are calling - (void)commit: on your EKEventStore instance after you have made your modifications?
Alternatively, there is a selection of methods within EKEventStore for saving and remove calendars and events that also offer a commit parameter which can immediately commit your changes. I would post the links but as a new user I can only use two hyperlinks.
- (void)saveEvent:span:commit:error:
- (void)removeEvent:span:commit:error:
Assuming these events are being added to a cloud based calendar, this should have the effect of synchronising your changes to your Mac.
I need to display some events on the iphone calendar from either a local app or possibly a remote server. I need the events shown in the iphone calendar to be readonly and am trying to figure out the best approach for this. Couple of questions to help me with the approach
-From ios iphone app can I write calendar events as readonly?
-If I need to go from the server to the phone can I give the phone a url to a icalendar that is readonly? which will disallow updates to the item on the phone?
-If I consume the events from the icalendar in to an iphone application can I tell what the origin of the item is? meaning can I tell the difference between things the user made locally, exchange, gmail etc.. and the icalendar readonly feed
Thanks
I'm afraid you cannot create a read-only calendar entry in a users calendar. After all, it's the users calendar, not your apps.
Nor can you create a separate calendar specific for your app that can read from a URL. You could provide the URL to the user and ask them to add it to iCal manually, but you cannot do it via the EventKit Framework.
You can't tell the origin of an event as EKEvent doesn't have any sort of public property that provides this information.
You would be able to infer which was the read-only calendar by iterating over the available calenders and looking at their titles. However, this would only work on the assumptions the user actually added your calendar manually, and they didn't change the title.
The best way to do something like this with all the features you want would be to add in-app calendar functionality to your app and make it completely independent of iCal and EventKit.
Here are a couple of projects which could help ...
Kal
Calendar UI
Is there any way to interact with the native Calendar application without using EventKit or EventKitUI? EventKit/EventKitUI lets you add/edit/delete etc. events in your native calendar, but I'm trying to find some way to add events to the native calendar so that when a user views an entry added thusly (viewed from the Calendar application, not from my application) by clicking on it, they see the item in a ViewController provided by my application (which has one or more extra buttons).
Is this possible, or do I have to emulate the entire native calendar inside my own application in order to get the calendar to behave the way I want it to?
Judging from the quarantine-like protection of other built in apps, I'd bet this is impossible. I'm only 99,9% percent sure, though.
I am looking into using event kit to display calendar events to our users, but I am trying to find a way to source the events from our website, since we already have thousands of events in our system.
Is there a way to have event kit use a .ics file from the web as a source? Or any other way to pull the data from another server?
Actually there is, and it is quite simple...
Create an IBAction and use the following code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://addressToYourics.ics"]];
And that it is. There will be an confirmation if the user wants to set the new calandar, and thats it.