UIWebView can't open link - ios

I have word document (.docx) with hyperlink, which points to my own app with specified app URL -> myApp://url. There is problem with webViewShouldStartLoadingWithRequest:navigationType: delegate event, when I open this document in UIWebView and try to tap on link.
It works, if the link is in full form like -> "File is located myApp://fullURL" in text, but if the link is hidden behind some word like "File is located here.", UIWebView doesn't recognize link and event is not fired.
Does anyone have the same problem? Regular hyperlink (http://) works well.

Related

How do I determine that a link is a calendar event from an IOS App and then add it to Calendar?

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?
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.

iOS WKWebView Handle File Download

I am facing the following problem:
In a web interface, file downloads are triggered with an anchor tag, like this:
<a href="/bla/blabla" download>..</a>
While Safari browser can handle this request and open a dialogue to handle the file, WKWebView treats this just as an ordinary link and does nothing with it. I want to be able to get the file handler dialogue that is normally there when using Safari.
Right now there are 2 problems and I do not see an opening there yet:
I can not detect a click on the element as it is treated just as a normal link. And I can not rely on the URL parameters to detect if it is a file since that is not constantly true.
Even if the URL is defined as a one leading to a file, I can not pass it to Safari since it does not share session info and cookies with my app's WKWebView.
Therefore, I would like to know if there is any opening in handling files in iOS WKWebView. Thank you.

MFMessageComposeViewController substitute full URL link inside SMS body with "clickable" text

Inside the app I have a MFMessageComposeViewController presented with pre-defined text. Inside this text I have a link, for example: "Hey, visit this site https://stackoverflow.com/"
In HTML we can do next:
site
And it will make "site" clickable. Is there any way to do inside the app, so that recipient will receive iMessage with text link, instead of full https://stackoverflow.com/ ?
SMS does not support HTML or URLs, just plain text.
All you can do is just add the URL to message and then it's up to the Message app to recognise the URL and allow the user to click on it.

UIDocumentInteractionController handling ics files

I've managed to open an ics file stored locally, and the UIDocumentInteractionController recognizes it the UTI as com.apple.ical.ics (which is expected). The data displays as I was hoping, for the most part:
I was under the impression from the docs that UIDocumentInteractionController would automatically recognize this ics file type and give some calendar-related options, however, there doesn't seem to be any way for me to add these events to my calendar from this view. Under the "Open in" menu, I see mail and dropbox as options, but not Calendar. If I email it to myself, I then can add the events from the mail app. Am I missing something with how this view works? Mobile Safari handles ics files in a similar way, except there will be an "Add all" button in the title bar. That's exactly how I thought this would behave. I'd prefer not to use EventKit at this point, since I'd just like it to mimic how safari handles the file.

How to open link to ePub file in iBooks, when link is in UIWebView

Links to ePub files automatically offer user option to load in iBooks--when the link is accessed from Safari.
However, I have an app with an UIWebView that links to an ePub file. I want to give the user the same option: let the link open in iBooks. However, that option is never given. When the link is tapped, the activity indicator spins for a few seconds, stops, and that's it.
To be clear so that no one flags this as a duplicate question: I do not want to open the epub file within the UIWebView or within the app at all for that matter. I just want the link to open (or give the user the option to open) the file in ibooks.
Any help would be greatly appreciated!
I don't think there's any way to control that, you have to use what the phone let you open.

Resources