Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've had a request from my client to convert their WordPress website into an App for Android and iPhone. I've looked around at a number of options and it seems doable especially for just the blog section as it's the rss that can be used as the db but I'm using the WP site as a customer and want to know if it's possible to pull all of the site's content out to save as RSS and use as the DB please.

Or any better approaches would be appreciated?

Many thanks

share|improve this question
    
check my answer for all the steps you need to take in order to complete your task –  Jessica Dec 4 '13 at 13:17

4 Answers 4

up vote 1 down vote accepted

Here is a list of points that will help you in order to make an iOS app for your WordPress blog:

You can either parse XML in the RSS feed, JSON by installing a JSON plugin in your WordPress or you can also parse HTML directly.

1) I would suggest using NSXMLParser and parse the RSS feed instead of using JSON. Reason being, if something goes wrong to the JSON plugin, or the developer just stops updating the plugin that you are using or the plugin crashes etc. the JSON data will be crashed and so does the data in the native app that you have made using the JSON plugin. On the other hand, RSS and XML data remains there even you blog crashes. This will not disturb the app users. Same goes with parsing HTML, i won't recommend it because if you change your theme and the structure of the HTML changes, the parse data in the iOS app will be effected and you will have to do the whole work again and then wait for the App Store submission. So lets stick to parsing XML in the RSS feed.

2) Parse the RSS feed using NSXMLParser. You can also use third party libraries available that parses the XML feeds but i would suggest to stick with the built in NSXMLParser as there is plenty of help available online for it.

2) To connect to the web services like XML feed, you can use third party libraries like AFNetworking or you can use Apple's built in libraries like NSURLConnection and other classes to connect and download the data from the webservice.

5) Here are some very easy tutorials for the steps above. How to Use NSURLConnection, How To Parse RSS with NSXmlParser

6) After that one of the most important thing is to download images asynchronously in the UITableViewCells where you are displaying your blog posts. I would suggest you to use SDWebImage library as it will save you a lot of time as its a project in its own and you cannot waste your time building something thats already there.

7) Then you have to create a UIWebView and when the row of any blog post inside the UITableView is tapped, you can use the link to segue in the UIWebView to show the actual blog post. You can use didSelectRowAtIndexPath in order to pass data between view controllers.

8) Below the view controller that contains the UIWebView, you can add functions like stop, refresh, sharing on Facebook and Twitter etc.

9) As you can see that is a lot of work and business people just think that its easy to develop an iOS app but the truth is that it takes some time to completely package the app and submit to the App Store. You can also outsource your project by using service like Convert WordPress Blog To iOS App that is completely for free if you share revenue with them but its your choice and i recommend you to code it yourself to have complete ownership of you app.

Rest is just a matter of choice of different functions you would like to make in your app to stand out from the rest. You can add a Facebook style sliding navigation controller on the left side to create and parse specific categories on your blog, you can use Flipboard style swiping in your Web View etc etc. For that stuff there are a lot of third party libraries available.

Hope this helps!

share|improve this answer
    
Hi Jessica! Thanks for the detailed description. As the client has not given the go ahead I cannot try this and mark this as the correct answer but I will go through it once I get started on it ;) –  SixfootJames Dec 10 '13 at 10:13
    
@SixfootJames I have created similar projects so i thought the information might help you. The answer i have provided contains basic guidelines, there are a lot of other small issues that you will face and will have to solve. Let me know if i am of any help. Thanks! –  Jessica Dec 11 '13 at 11:19
  1. Check out JSON API plugin. It will allow you to have a RESTful API for most of the content on your website.

  2. If you don't want to have an API in WordPress (i.e. you want it on a different domain/subdomain, have separate codebase etc.), you could do the same through pure PHP, or using a microframework, such as Slim.
    In this approach you would load WordPress through requiring /wp-load.php. All functions would become available to you (such as get_posts()) and you would still be able to query the database the same way as if you were writing a WP plugin:

    global $wpdb; $results = $wpdb->query("your query here");

Notes

There are a couple of tips to get better performance using the second approach:

  • Skip loading theme engine as you probably won't need it if you serve everything in JSON:

    define('WP_USE_THEMES', FALSE);

  • Prevent executing WP cron on any of the API calls. This will make sure there will be no hangs in the API calls because the cron is being executed in the background.

    define('DISABLE_WP_CRON', TRUE);

share|improve this answer
    
Thanks Topsite. I will have a look into this when the client gives the go ahead ;) –  SixfootJames Dec 10 '13 at 10:14

A solution may be to use something like json-API plugin to provide a simple API to your contents.

share|improve this answer
    
I will have a look into this when the client gives the go ahead :) –  SixfootJames Dec 10 '13 at 10:15

I believe you can do it through API, however you should use a premium paid service from some great providers. They provide Free Android/iOS App which loads contents from your Wordpress site.

share|improve this answer
    
Please expand the answer with more details of how to solve the problem whether with code or with custom functionality - answer like soliciting is not a good answer. –  Mayeenul Islam Nov 20 '13 at 6:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.