Reputation: 1038
I have an app which uses a UIWebView and cordova/PhoneGap. One section of the app has a 'Download Calendar' feature, which has been giving me a lot of issues on the native iOS side. The basic function of Download Calendar is an ajax call (type: POST) which returns formatted ics data. In mobile safari, this functions perfectly. A table view will slide up from the bottom and give me the option to add the listed events to my phone's calendar. I think this is just how safari normally handles ics files. Now for my issue...
UIWebView doesn't seem to want to behave this way. When I tap "Download Calendar" nothing happens. To get the ics data, I used an NSURLConnection to get the response, and put it in an NSData structure called webData. With _webData, I'm making this call:
[self.webView loadData:_webData
MIMEType:@"text/v-calendar"
textEncodingName:@"utf-8"
baseURL:[NSURL URLWithString:@"calshow://"]];
In my shouldStartLoadWithRequest:
method, I'm telling any 'calshow://' urls to open the calendar, but I don't think this gets me anywhere, since I can't pass the NSData along with it. My main question right now is, can my UIWebView mimic how safari handles this ics data? If not, can I do anything useful with this NSData?
BEGIN:VCALENDAR\r\nPRODID:-//bobbin v0.1//NONSGML iCal
Writer//EN\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT...
UPDATE: I was able to get this working in a UIDocumentInteractionController
, where it displays the dates and times exactly how safari would handle the data, however, there isn't an "Add All" button or an "Open in Calendar..." option. The UTI is correctly set to com.apple.ical.ics
, but I'm not presented with any usable options in the view.
Upvotes: 3
Views: 2182