Add ical feed to native calendar in Ionic - ionic-framework

We develop a ionic 3 app for iOS and Android based on a series on events. All events are stored on the server. Several clients can create, edit and delete events. All clients subscribe to these events.
Some of our customers would like to add these events to the native calendar.
We currently have a ical-feed which they can add to their google calendar as "a seperate calendar" and then the google calendar will automatically sync these events.
This is nice but not very userfriendly to setup.
It is also hard to do on iOS.
We whould like the user to subscribe to his events through the app. Not one single event but the entire list of upcomming events.
The ionic native calendar plugin lets us create events from the app which is nice but with the methods available there would be a lot of work to be done to be able to sync events with native calendar every time the app fetches event updates.
The list of events can contain new events, changed events and also if a event is deleted the updated list will no longer contain the deleted event. Also all properties of an event could change so to be able to determine a event, we need to use the event ID (which comes with the event list from the server).
The events displayed in the native calendar is mostly for display. Changing events is done in the app or on a web interface (server).
This means that the native calendar sync can sync one-way: app->calendar
How would you recommend us solving this issue from the ionic app?

Related

How would one access the events data from a web calendar for use in displaying in a mobile app?

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.

EventKit synchronization questions

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.

Readonly items in ical iphone

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

iPhone Application Combined With Facebook

I need to know if this is possible. I want to develop an iPhone app that uses facebook credential to login (this is possible i know) and the create an event (like a dinner) and invite friends from facebook. When the time for the event comes (like 15-20 minutes before the start time) all the users that are attending the event can see how far are the others participants to this event using GPS (Core Location lookups) and see on a map as they move towards the place of the event
Yes. Everything you have described in your question is possible.
However, iPhone doesn't allow things like that to run in the background - your app would only work if each guest had the app open as they were travelling towards the event. The app would then update a server somewhere with their locations.
You might be able to do this with a notification that told them to open the app 10 minutes before the event started?
Android allows background tasks so you might want to write this for Android devices first and then make an iPhone version later?

iPhone: how to interact programmatically with the native Calendar application

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.