EPub 3.0 and HTML Forms - forms

I am creating an epub3 with a form inside. Is it possible to save the information that was inputted in the form locally when the user is offline and send it to a web service if the user is online?

THIS is a good question! Finally...
OK, for the first part of your question (saving the information) you can use localstorage, for some great info on that go here: http://diveintohtml5.info/storage.html.
The next part of the answer is not quite so simple: ideally you could just use some sort of try catch with an XHR request, but chances are that won't work because most ePub3 readers (actually, pretty much all of them except Readium) don't support XHR or external request functionality. See this post for more info on that: http://beneaththeink.com/blog/who-supports-epub/.
If you want your book to be distributed through any of the "normal" channels (pretty much just iBooks since you need Script support at this point) you won't be able to send the data at this point in time...
However, if you will be distributing the book yourself for use on Readium and iBooks (or if you want to plan ahead and hope for support) there are a few hacks you can do. My personal favorite, is embedding the data in a media request (IE www.yoursite.com/fake.m4v?data1=localStorage.data1&data2=localStorage.data2) and pulling out the data on your server. This would be nested in a try catch and activated whenever the book is opened.
If you include the base url (www.yoursite.com) in the .opf file, as well as at some point in the chapter which contains the script, this will work in iBooks! If you don't include it in the .opf the request will get blocked right out of the gate... For more information on why this won't work in the actual iBookstore check out this post: http://beneaththeink.com/blog/external-video-in-ibooks-epub-files/.
Best of luck!!!

Related

How to create a news like iPhone app that updates weekly

I have created a few small apps for the iPhone so I have some experience. An organization that I'm in asked me if I could program a weekly newsletter app for them. I though it would be a good challenge so I agreed. My question is: how do I get the app to update weekly without the users having to re-download or manually update? Do I connect to a database or a website? Can anyone send me the link to a good tutorial? I wasn't able to find one.
Thank you!
Your question is very general but I could give you some suggestions.
First, you need to connect to a service that provides you news info. This is needed. The service could send you an xml that you can parse and display, for example in a UITableView. XML is not the only solution. You could use also JSON.
For parsing XML I suggest you to read GDataXML, while for JSON JSONKit framework. But there are also other valid framework out there.
Then, to save data it depends on what kind of data you deal with. Here you could find different ways to save your news. Save an XML that contains your news, serialize data and save them in the local filesystem or use Core-Data.
To update your news without user actions, you have to save the last time when the app has downloaded news (for example in NSUserDefaults) and each time time the application is "activated" check for that date and update news if necessary.
Out there there are plenty of tutorials on how to (in parenthesis I inserted classes or framework that you could have a look):
consuming web service on iPhone (ASIHttpRequest - no more supported, NSURLConnection class, AFNetworking)
dealing with XML file/data and theirs parsing (GDataXML, touchXML, etc.)
dealing with JSON messages (JSONKit, etc.)
managing documents (NSFileManager class)
using Core-Data
using Property-List and/or NSUserDefaults
First three cover the first step (download). Other three cover the second one (save). Obviously you have not to use all of them. For example a configuration could be:
NSURLConnection for service, GDataXML for parsing XML data and Property-List for save data.
Hope it helps.
A simpler approach would be to make it a pure web app and update the website weekly.
Your content providers are going to have to do those updates anyway.
Check: Adding Newsstand Support to Your App or Tutorial: How To Make Your App Work With The Newsstand

Displaying Server Side Content in iOS app - Approach Needed

First, Thanks for your help - I greatly appreciate it. The core solution I am trying to figure out is how to display content from a CMS inside of an iOS application. The application I am planning is a company intranet / portal used to display news, alerts, and other content to sales associates at our firm. One approach a friend suggested as build the content in HTML and display in a web view, This does not sound like the best solution too me. How do apps like Facebook, Flipboard, etc display server side content inside the applications.
The application / employee portal will consist of news stories, alerts, documents etc in text form accompanied by images, video, audio. The sales associates will use the application to navigate through the content stories, read, review, etc with all of the nice features of ios, the sliding and flipping of pages and content, etc.
The content and user roles would be managed by a CMS (Joomla, SharePoint, Storage Room, If you know of something better please let me know). The app content would also need to be accessible when offline, what is the best approach for this solution? Is there any existing code bases / libraries that I could leverage for this?
I am having trouble understanding the best process for 1) rendering / displaying the CMS content inside the the App (HTML webview or Another approach?) and 2) How do pull the content, images, video, audio down to the device for offline viewing?
Any ideas you might have will help. If you think there is a starting point set of code, or an example model we might be able to use as a starting point, please let me know.
Thanks You! I greatly appreciate any input.
This is all possible for ios app. you have to made web service for your apps. At the starting when an app is start the data are store in local database like used sqlite or core data in your app. so after that if there is no internet you can stil access your data.
A framework/product like TapLynx or Appcelerator might be a good fit for you. Look at the product demos and showcased apps to see whether they support the kind of thing you want to do.
HTML webviews are a good mechanism for displaying rich content on the device. As to whether you'll display HTML which exists in the CMS, or pull down data and format the HTML on the device, it's really up to you.
I'd go about it creating an API on the server. You can download the data as raw XML or json and parse that content into workable objects. As for how to download pictures and other data, just include the URL string for the picture in the XML / json download.
See the iOS downloading programming guide for details on how to do download data from a server.
Also, as hiren said, you can save the downloaded data using core data.

Sending Data to Website From iPhone

I'm creating an iPhone Game where I want the user to get a unique numeric code when they first launch the app, that way when a friend of that user opens it, he/she can input that code and both users can get rewarded. I haven't encountered any issues regarding that, however what I want to do is make it to where the app registers the code given to every user and saves it to a website of some sort. That way when the other user enters the code, it will load the data from that website and check if it's registered. How would I manage to save the data onto a website? and also What free website could I use for this without having a character limit on the body page?
-Thanks in advance
Your thinking is correct, in that you need to save your data somewhere online, but you don't really "save data onto a website" in the way that you're describing. "Free Website" services usually serve a different purpose entirely - that of serving up public html pages. Sure, they can take the form of a CMS (like wordpress.com or tumblr accounts), but using that as an interface for storing your application's data is not something they're typically designed to do.
For something like this, where you have a public iPhone app that requires secure access to custom strings, you really want to have control over your own web server (different than a domain name, btw), and interface with a database on that server. This will come at a cost, and will involve more code than you're likely to find someone to write for you on here. Sorry to say it, but hey if someone wants to prove me wrong I'd love to see it.
Because all you need to store & retrieve are random strings (basically referral codes... if I'm understanding correctly), your database needs are pretty simple. If you're not familiar with things like PHP / MySQL, and you don't want to learn, it might be worth reaching out to some server-side developers for help. Unless there's more to it than you describe, you can probably find someone to help you for relatively cheap.
Good luck - and I'm sorry there isn't a simpler answer for ya.
You can send data using NSURLConnection. Just create an NSMutableURLRequest and call its -setHTTPMethod: method with “POST” as the HTTP method. Then, set its body and header fields appropriately, and you can use NSURLConnection to send the data.

iphone - retrieving information from the internet (rss alternative?)

(Very) basically my app is just a load of information collected from the internet - eg: someone can log into an admin panel on a website and update their app from there. The information gets put into a mysql database.
The way I thought about going about this was to use an RSS feed - it works for blog/twitter feeds, so I thought why not do it for the rest of the information that I want to get.
My question is, is this a suitable way to do it? Basically just make dynamic XML files (php scripts that output XML) and parse them on the iphone, or is there a better way to do it?
I'm not looking for a full blown tutorial, just maybe a few keywords that I can go off and look up myself - or a "XML is the best way... stick at that". :p
Thanks a lot.
I personally like JSON more than XML, since it creates less characters to transfer the same data = less bandwidth/transfer used and faster response.
You can use a JSON library from here or just stick with XML since you're familiar with it. I guess it's just a matter of personal preference.

what language combination should I use to permanently modify a webpage?

I'm trying to make a page with 2 fields (email and feedback) and 1 button. When the user clicks on the button, a table on a page else where is filled in with the data, permanently.
Does anyone have recommendations of how I should do this? I'd like to avoid having a script send me an email, or writing to a database. But if I have to, which ever is easier to configure would be prefered.
Thanks,
Matt
So you want a comments system like you find on most blogs? You'll need to store those comments somewhere, probably in a database. As for how to do it, that would depend entirely on what you already know and what the site is currently written in. You could use PHP and MySql if you already have those skills, or ASP.Net/SQL Server, or if you want to be down with the cool kids you can use Ruby on Rails or Python/Django.
If you post what languages you already have experience in, and/or what the site is written in you might get a more specific answer :-)
There're 2 types of scripts: server side and client side. The client side script (JavaScript) stores info only for particular visitor on his computer and this can't be seen by anybody else.
You need a server side script to save feedback on the server. The language or technology depends on the hosting server you use. Not all hosting services allows server side scripts. You need first to find out what scripting languages and technologies are supported by your hosting provider. Then we can help you more.
ADD:
For an unexperienced persons I recommend to search for hosting services which has most needed functionality. Something like blogs, etc. On such services you could create pages that will have comments and feedback and many more.
While it may seem outdated it's not necessarily a bad design. You can use PHP or Perl (due to it's string parsing capabilities) and simply store the main page on the disk.
Here's your sudo code/design...
You'll need need an html page that looks as follows
<tr><td>email</td><td>comment 1</td></tr>
<tr><td>email 2</td><td>comment 2</td></tr>
<tr><td>email 3</td><td>comment 3</td></tr>
Then you'll need a php script page that will read this html file in and display it.
The php page will also contain code for dealing with a user submitted comment. When a user posts a comment you need to open the html page with the rows in it and append to that file.
You need to be careful with this design however because you may run into write concurrency issues if two people attempt to read the file at the same time. Add code to handle this gracefully accordingly.