I run in the situation that at least local calendars of type EKCalendarTypeLocal are listed by EKEventStore but arent't shown and can not be selected in the calendar app on iOS.
if ([eventStore respondsToSelector:#selector(calendarsForEntityType:)]) cals = [eventStore calendarsForEntityType:EKEntityTypeEvent];
else cals = eventStore.calendars;
I found out that it has probably something to do with iCloud Accessing programmatically created calendar on iOS device.
I also created a local calendar successfully and could add events to it. This created calendar was not listed by EKEventStore but I get it with its identifier:
aCal = [eventStore calendarWithIdentifier:calId];
After I removed the iCloud account in the testing device all local calendars are shown also my own created. Is there any possibility to check if local calendars are hidden? So I can wrote an info text or hide them as well.
Have u solved?
Anyway, i'll try to answer.
As i understand iCloud don't let local calendars to be shown. If u turn of iCloud and then lead him back to on u will see a message like "Would u like to add your local calendar to iCloud?", so ... if the problem is just see the calendars in iCloud, extract your EKCalendar and change source in a EKSourceTypeCalDAV instead than EKSourceTypeLocal ... should be ok
Related
I've been using EventKit for years in my app (since macOS 10.10) but it's having an odd problem in Mojave.
Previously once I received an EKEventStoreChangedNotification I could query for changed reminders with this:
NSPredicate *predicate = [self.eventStore predicateForRemindersInCalendars:#[self.taskCalendar]];
[self.eventStore fetchRemindersMatchingPredicate:predicate completion:^(NSArray *reminders) {
self.allFetchedTasks = reminders;
}];
Worked like champ. Setting a breakpoint within that block, I could switch to Reminders, change the task title, instantly pop back in the debugger and the reminders array would have the change (via "po [reminders.firstObject title]").
However, now in Mojave the fetch appears to return old information. I get thrown back in the debugger as soon as I change the task title in Reminders but the reminders array still contains the old info. That is, [reminders.firstObject title] is still showing the original title not the title as it exists currently in Reminders. I can continue to change the title in Reminders and each time I'm brought back into the debugger and I still see the original title.
I also attempted to use calendarItemsWithExternalIdentifier but it also returns the original value.
If I relaunch my app then it grabs the latest info but, again, subsequent fetches due to change notifications return the original value.
It doesn't look like Mojave's EventKit has any new caching I can control. Is there something else I'm missing? Do I need to reconstruct my self.eventStore each time now?
This has been fixed in Apple's macOS 10.14.4 Beta 3 release.
I worked through the iOS Quickstart Guide provided by google to notice, that it is outdated for a very long time already.
So I researched the whole day to find out how it is supposed to work now but I did not find a working solution / description on how to do it.
I have an iOS App with a calendar. The user can decide which calendar should be used to synchronise calendar events between app and calendar. Google Calendar and Apple Calendar should be supported. The Apple Calendar synchronisation is working perfectly. For the Google Calendar I could not find any solution yet. It should be possible for users of an google calendar to synchronize all events with our iOS app (including adding, removing and changing events).
Is there any source for that which is not outdated and which is describing on how to do it?
Google has an example app on Github here: https://github.com/google/google-api-objectivec-client-for-rest
If you dig through the app, there's an Objective-C example of creating an event, it should give you a good place to start for Swift as well:
- (void)addEvent:(GTLRCalendar_Event *)event {
GTLRCalendarService *service = self.calendarService;
GTLRCalendar_CalendarListEntry *selectedCalendar = [self selectedCalendarListEntry];
NSString *calendarID = selectedCalendar.identifier;
GTLRCalendarQuery_EventsInsert *query =
[GTLRCalendarQuery_EventsInsert queryWithObject:event
calendarId:calendarID];
self.editEventTicket = [service executeQuery:query
completionHandler:^(GTLRServiceTicket *callbackTicket,
GTLRCalendar_Event *event,
NSError *callbackError) {
// Callback
self.editEventTicket = nil;
if (callbackError == nil) {
[self displayAlert:#"Event Added"
format:#"Added event \"%#\"",
event.summary];
[self fetchSelectedCalendar];
} else {
[self displayAlert:#"Add failed"
format:#"Event add failed: %#", callbackError];
}
}];
}
Additionally, you can also use the EventKit and let the user sync their calendar as they see fit, as described here: ios Add Event to google calendar
I m working iOS calendar events in my app.
I dont want to add duplicate event i.e if event is not modified i dont want to add it.
I m using saveEvent:event span:EKSpanThisEvent error:&error method from EkEventStore. As per documentation, this method returns NO if event is already in store.
But m getting duplicate events also in Calendar. Please suggest me something if m doing wrong anything.
Thanks.
is it possible for my app to programatically add events (with permission from the user) to the iphones calendar?
cheers
w://
It's available in the iPhone 4 SDK, so in Monotouch. Take a look at EKEventStore and EKEvent. Here's the Apple docs.
Here's an example from a snippets page I keep:
public void CalendarEvents()
{
EKEventStore store = new EKEventStore();
EKCalendar calendar = store.DefaultCalendarForNewEvents;
// Query the event
if (calendar != null)
{
// Searches for every event in the next year
NSPredicate predicate = store.PredicateForEvents(NSDate.Now,DateTime.Now.AddDays(360),new EKCalendar[] {calendar});
store.EnumerateEvents(predicate, delegate(EKEvent currentEvent, ref bool stop)
{
// Perform your check for an event type
});
// Add a new event
EKEvent newEvent = EKEvent.FromStore(store);
newEvent.Title = "Lunch at McDonalds";
newEvent.Calendar = calendar;
newEvent.StartDate = DateTime.Now.Today;
newEvent.EndDate = DateTime.Now.Today.AddDays(1);
newEvent.Availability = EKEventAvailability.Free;
store.SaveEvent(newEvent, EKSpan.ThisEvent, new IntPtr());
}
}
A lateral thinking way around this is to consider creating an ICS file, then creating an email (which can be done programmatically) and then send it to the user or whomever they want. This is how I'm getting around this issue in my code. The beauty of it is it also doesn't create the sense in the user that your application is going to manage the dates, i.e. if they change something in your application that you'll cancel and rebook things on the fly.
It's not possible in the official iPhone API, so I doubt it's possible via mono touch.
Not directly possible with the SDK. You might try getting the user to subscribe to an online calendar published from your server, then upload events to that, but you'll probably run into all kinds of syncing issues.
I would like to know whether we can create a calendar using NSCalender and show it in our dedicated application. We can create a NSCalender object by
****NSCalendar *japaneseCalendar = [[NSCalendar alloc] initWithCalendarIdentifier : NSJapaneseCalendar];****
But how can we show this calender in out application. Is there any way to show the default calander in our application when a user click a button.
Please please guide me, i am hanging here for last few days.
Thank You
Rahul
NSCalendar has nothing to with the Calendar app on the iPhone, it's simply a class used to represent a calendar for whatever reason you need one.
I'm not sure that this can be done on the iPhone from within an app.
-
After re-reading your question, I think I misunderstood what you were asking.
If you want to display some kind of calendar view within the app using that particular calendar, you'll have to create you own view and draw the calendar into it.
You may be able to find some code on the internet to accomplish this already.