https://torbjornzetterlund.com/wp-content/uploads/2016/05/bikerecipes-e1467038988798-960x600_c.png

Using WordPress instead of Parse.com


If you have not heard it yet, Parse announced they’re shutting down their backend as a service. If you’ve built an mobile app with Parse as your backend, you need to migrate to another backend platform or set up your own parse server, as Parse is open sourcing the parse server.

The good news is that they’re giving developers 12 months to find a new solution, and they’re providing a path to running your own Parse-compatible service. There’s a great migration guide that covers exporting Parse data to MongoDB, and running a Parse server built on Node.js and express.

WordPress instead of Parse.com

I have taken a different route, instead of setting up my own parse server, I have taken the route of using WordPress as my backend. My Android app is very simple, it’s a recipe guide for cyclists.

Screenshot_20160624-163637

The app is very simple, in that it shows the recipes and you can select recipes by category. My database model requires a recipe table and a category table.

WordPress Plugins to use

To be able to emulate exactly the same data model as on the parse.com service, I needed to take help of some specific plugins to be able to create the same database model as on the parse.com database.

What did I do

I configured the Custom Post Types UI creating a new Post Type

Add_Edit_Post_Types

When configuring I made sure that I set the REST API to true.

I then created a custom category that is linked with the custom Post Type.

Add_Edit_Taxonomies

Make sure your REST API is set to true.

Next, I created my Custom Fields with Advanced Custom Fields (ACF) – Edit_Field_Group

I made sure that the post type for my custom fields is set to recipes.

Adding Recipes

Now after I setup the ACF and CP UI – I can start adding my categories,

Recipe_Categories

I wrote the plugin WP Custom Category Images to add an image for each category. After I setup my categories, I entered my recipes:

Recipes

When all was done, now I can start using my mobile app to show the content in my mobile app. To do that I needed to enable WP REST API V2 and to register my custom recipe images with the WP REST API V2, I did that by creating a plugin WP API V2 Recipe Category Images which with a few line of code register the IP. I could have used a plugin like Code Snippets to enter the code, I went with a plugin.

Testing

I use chrome, so for testing, I’m using the chrome addon Advanced REST client – you can also test in the browser.

My Recipe API call – https://thelonelycyclist.org/wp-json/wp/v2/recipes/

My Recipe Category API Call – https://thelonelycyclist.org/wp-json/wp/v2/recipe_categories/

Want to try out the Bike Recipe app and get some ideas for your next meal, you can download it from here. en_app_rgb_wo_45

That’s it, I’m not going into the coding of the Android App, if you are interested in the android source code, you can buy a copy from me – 

If you have any questions you can contact me or you can use the comment fields below.

[contact-form-7 404 "Not Found"]

Menu