0

I have written an iPhone App that looks at a webpage. (I have authorized the App to access Calendar.) One of the links is a calendar link. When I look at that link with Safari, I get a message.

https://www.dropbox.com/s/opzhxcrg8ye2z4v/Screen%20Shot%202018-11-23%20at%201.17.15%20PM.png?dl=0

"The website is trying to show you a calendar invite. Do you want to allow it ...". I can then add it to my calendar. However, when I open that identical link inside my app, my app does not recognize it is a calendar link and then I get options to either Open, Add to Read List, copy ...".

https://www.dropbox.com/s/wd7n8n9bz764wih/Screenshot%202018-11-23%2013.20.53.png?dl=0

My question is how to get my App to recognize that a link is a calendar link?

Howard Matis
  • 51
  • 1
  • 6

1 Answers1

0

One determines what should be in the file by the suffix and the MIME content type. For icalendars, the suffix is .ics and the MIME content type is text/calendar. If a link does not have .ics suffix your app can ignore it, if it has a .ics, then it should check the header for the mime-type.

What is a MIME type? https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

What a browser or device actually does with the file depends on what the user has set in the settings. EG: a .pdf will topen in the way that the user has told the browser to open .pdf's - either in browser or adobe reader.

EG in windows for development purposes, I have specified that calendar links (links with suffix .ics) should be opened in my editor rather than my calendar.

anmari
  • 3,242
  • 1
  • 12
  • 12
  • Safari is smart enough to know that it is calendar link without any MIME type. My question is how does Safari (or Chrome) know it is a calendar file and my App does not. I did not create the Calendar link so I can't change it. I want to know how to make my App act in the same way without renaming the link which requires me to make a completely new link which is very complicated. – Howard Matis Nov 24 '18 at 04:55
  • You can determine that it should be a calendar link from the suffix. The suffix should be .ics. – anmari Nov 24 '18 at 05:31
  • That does not answer my question. I want to get my app to use the link WITHOUT changing the the suffix. As I said Safari and Chrome can tell it is a calendar link so why can't my app. I can't change the suffix because I am using an existing link that cannot be modified. – Howard Matis Nov 24 '18 at 12:57
  • Here is a link that will open up a calendar event in Safari or Chrome. Notice there is no suffix: https://oakland.legistar.com/View.ashx?M=IC&ID=651602&GUID=ED6E3EA1-90D2-4AC1-8C06-F2272C19882F – Howard Matis Nov 24 '18 at 19:33
  • Hi Howard, a no suffix url indicates either a rewritten url or a dynamic (eg a php url) . In this case when one 'opens' or clicks on the url, a file "CalendarExport.ics" is received. You don't need to rename as when the url is opened, or requested, "CalendarExport.ics" will be delivered. – anmari Nov 26 '18 at 01:32
  • In theory, you should be able to pass the URL to IOS and it will take it from there, just like it does when one clicks on such a url in gmail, or browser – anmari Nov 26 '18 at 01:35
  • Here is what happens. When a request a calendar even, my app opens, the app gives me several choices. One is to save it to my reading list. I then do it. I then go to Safari and open the saved link and then I am asked to save the data to my calendar. I want to change this two step application to a one step and save the calendar event in my app. That is what I need to figure out and need help on doing. – Howard Matis Nov 26 '18 at 19:12
  • The problem here is that that file is not a good ics file. It does not have the right MIME-TYPE. Your app may work better with a better quality ics file. Giving the url to one of the ics validators that url, gives: Warnings Invalid MIME type detected, should be 'text/calendar' (found MIME type 'text/html') near line # 1Reference: RFC 5545 8.1. iCalendar Media Type Registration Problem! Found 2 errors Errors Missing DTSTAMP property near line # 5Reference: RFC 5545 3.6.1. Event Component Missing UID property near line # 5Reference: RFC 5545 3.6.1. Event Component – anmari Nov 27 '18 at 03:22
  • Just noting, I have .ics knowledge NOT ios developer knowledge, so the above may not solve the problem. Googling indicates that there are ways to add 'action extensions' to apps. Perhaps research and rephrase question to get the attention of ios developers? Good luck – anmari Nov 27 '18 at 03:26
  • Might be an apple bug according to this: https://discussions.apple.com/thread/8350974 – anmari Nov 27 '18 at 03:28
  • IE: If you can get it working in browser / mail for a normal ics url, then may work in your app. – anmari Nov 27 '18 at 03:48
  • That apple bug is solved and it currently works in Safari. I use the link in Safari and I get the proper response - https://www.dropbox.com/s/4kbr14x1yyrgayh/Screen%20Shot%202018-12-02%20at%2012.22.41%20PM.png?dl=0 The event can be added to calendar. However, when I view the identical link I get a different response - https://www.dropbox.com/s/mmdw6iiax4ppp0h/Screen%20Shot%202018-12-02%20at%2012.19.58%20PM.png?dl=0 If I add the link in my app to my reading list, I can go to Safari and then save the calendar event. I want to add the link directly from my link and not change the MIME-TYPE. – Howard Matis Dec 02 '18 at 20:24
  • Once you past the 'determining if it's a calendar event' part, and just want to pass it to IOS, I can't help much further, as I'm not an apple developer. The docs imply that ios openURL should recognise what apps it has to handle a valid url/file. https://developer.apple.com/documentation/uikit/uiapplication/1648685-openurl?language=objc. Perhaps if you rephrase the question as a straight ios Inter-app communication question?, noting the research and testing you have done, you may get some ios experts to chip in. – anmari Dec 03 '18 at 07:35
  • I just reported this as a bug to Apple with Problem ID 46443697. – Howard Matis Dec 04 '18 at 06:41