I am relatively new to creating apps, I noticed on some apps that there are images or content that will change with our the app having to be updated, how is this achieved? I have been looking everywhere I could think of and have came up empty.
Thanks for any advice.
As Michael mentions you can use a UIWebView and UIImageView to render the contents of a particular URL. However, most dynamic content on the iPhone is achieved using web services rather than directly rendering a web page.
If you are not familiar with web services, you can think of them as a stripped-down form of content; they are the link between the database and the client. In this model, the client requests data from the web service, the web service fetches from the database, and the client renders the web service response as he sees fit.
For example, you can use a JSON-based web service to return content like {"Movie":"Title","Review":"Pretty good"} and create a content view with two UILabels, one bigger and one smaller, to reflect this:
movieLabel.text = [[JSONParser parseString:[WebServiceClient JSONForRequest:&request] movieString];
reviewLabel.text = [JSONParser parseString:[WebServiceClient JSONForRequest:&request] reviewString];
Read more about web services and iOS at http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service
These are typically apps that get their resources via URL references to servers providing content (graphics, images, the latest "sale" page or whatever).
Many iOS classes (such as NSData or NSString) have initializers like initWithContentsOfURL:encoding:error:. Other classes (like UIImage) can be easily instantiated with data downloaded from a URL (imageWithData).
You can also embed web views (UIWebView objects) into your app and simply point that web view at some convienent URL on your server.
Apps can request data from a remote server and download it to the app. You can use classes in URL loading system to interact with remote servers. Here is a [link] http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/URLLoadingSystem/Concepts/URLOverview.html for further reading.
Related
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.
Im new to website development and design so apologize in advance if the question is redundant.
I have a program where a client, using a URL string fetches a XML file from a webserver. This would be no problem right if it were a simple URL with no security or no CMS (like Joomla) involved: Just put the exact URL string and the client gets the file from the web server, done.
But, how would the process work if the URL is on my site hosted on GoDaddy and using a Joomla CMS?
Im trying to understand how the same process of fetching a file works on a hosted server using a CMS. Since I just made the transition from my site being on my school's servers to having a Joomla website Im hosting on goDaddy.
I mean where would I put the file if I also want the file to be accessible only if the client authenticates itself first. Just to be on the safe side. I mean is this how normally things work in mobile apps? I have a client program thats a iPhone app and within the app I have a XML file which is used as a data source for my UITavleView, but I want to check some URL to see if an updated version of the XML file exists. My app side programming is mostly done, now Im trying to learn the server side things I need to do to make this process happen with Joomla and my own hosted site
I donot understand how would the process work in that case. I mean, what are the things I would need to do on the server side to and the client side to make this possible?
Please help me understand or if you could point me to some links where these steps are illustrated...or if you could give me some Google key words I can search for to learn about this process.
thanks a lot
The fact that you have a CMS does not generally change how you access a file within the file structure of your domain unless the CMS protects certain directories. In this case, Joomla does not so you can directly access any file you wish. Depending on the sensitivity of the information you are trying to retrieve, you can protect the directory through your domain management panel. If it's not particularly sensitive, the authentication can be done by the app since the URL you are accessing can be easily hidden from the user.
It seems like that would be the simplest solution since the app will have access to user information by nature of where it resides.
Do I need to implement my own sync methods in order to make an offline web app (html+css+js) stay up to date with changes made on the server (and viceversa)? I'm using MySQL on the server side.
I read Two-way sync between iPhone application and web application with some pointers but I think they're talking about native applications when they mention CFUUIDCreate and I wander if this is possible for the Web.
Does someone have some code to share or maybe can point me in the right direction?
Thank you!
P.S.: I hope my english is not that rusty ;)
To store static contents on the client-side, as Jethro Larson said, the Application Cache Manifest is the way to go to cache the static contents of your website (HTML, CSS, JS and images).
To handle dynamically generated contents offline, you can use javascript templates. There are several solutions for this.
To sync the two databases, there is a project called persistence.js (persistencejs.org) which is a javascript library which offers a unique API to work with WebSQL databases, Local Storage, etc. They have a plugin for this library called persistence.sync (persistencejs.org/plugin/sync) which syncs the remote database with the server's one. It consists of POST and GET requests to a specific url that you can configure (for example yourapp.dev/sync). They have an example back-end written in node.js and here is one for Rails. It's simple to understand and persistence.sync is well documented.
Look at the offline cache:
http://www.webreference.com/authoring/languages/html/HTML5-Application-Caching/
http://www.google.com/search?q=offline+cache+html5
http://www.slideshare.net/search/slideshow?q=offline+cache
I'm writing a native iPhone app that contains a UIWebView component. This component accesses an internet webapp and the webapp stores data offline using HTML5 local storage.
Is it possible to access this local storage data from the native app ?
I was looking to do something similar to this. In short, the DOM and all elements are not directly accessible. However, you can hack things up to get at the data. What you have to do is inject your own javascript into the downloaded webpage. Then evaluate the results.
This page shows the mechanism for doing it:
http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview
Then you just need to know the name of the database and create some javascript to return the values in a JSON string. Use a cocoa JSON parser to create objects from that string that you can use in your native app.
Is it possible to pull information from a website and display it in an iphone application?
I am looking to pull the current temperature and barometric pressure for an airport from the http://adds.aviationweather.noaa.gov website and display those two pieces of information in an app.
This sounds like a common task that programs do all the time but I'm not sure how it's incorporated into an app.. (what is the process of pulling webdata called?)
What methods or tools are available to do this? I am unfamiliar with handling web data for iphone at this time.
If they have an actual feed for the data, you could access it using NSHTTPRequest and parse the results.
If you need to screen-scrape the data off the page itself, then I would highly suggest creating your own web service to do the parsing and have your iPhone app talk to your web service. The reason being that if they update the page in a way that breaks your screen scraping you would only have to update your web service instead of deploying an update out to who-knows-how-many iPhones.
Just use an NSHTTPRequest and all the related classes to assemble a standard HTTP GET request for the site with the data you need. If there's a data feed (XML, JSON, etc.), you should find out what that URL is and use it instead of parsing the actual HTML of the web page. If not, the method is called "screen scraping" and it basically involves you writing a regular expression to parse the HTML of the web page returned from the server. Again, don't do this unless there is no alternative data feed you can use.
If you need to parse XML, see NSXMLParser. There are open-source solutions for parsing JSON in Objective-C. Just Google around for them.