How to use WordPress Backend in Building PhoneGap APP

Interested in building an app fast and easy? Then this is the place to be. Native apps take ages to create with some consuming hours which can lead to months before an app is completed and the app may still be unsuccessful, in addition coding can be very complex and might also require a huge investment on capital. However there is a solution! With cross platform applications, which can reuse the same of code, have the same design and developing made easy, PhoneGap is the best option.


David Rust Smith is a happy PhoneGap app developers after getting value for his time and effort. The developer behind Heart Spark app, which he created to help save cardiac arrest victims by having a list of where the nearest defibrillators are and also users have a chance of submitting new ones and approving the quality of the existing ones. David enjoyed various PhoneGap features including Global Positioning System (GPS) tracking, file storage, web communication, and connection to social media in this case Facebook and Offline Maps. His decision to use the app was reached due to it being easy to manage, code is reusable plus JavaScript programming used is easier than Java which is used to create native Android Apps.


Hot-Dog or legs is another app developed by David Smith using the same technology, and is a hilarious and entertaining game, in which players are required to differentiate between hotdogs or legs in various images. Sounds hilarious try it out and laugh your head off!


Read Here: PhoneGap App Developers. Let us make you a high quality Android iOS App


Other apps are available, from educational, to music discovery platforms or utilities, apps which utilize real world events, and Untappd captures my attention. Untappd was developed using PhoneGap app, and is available for all major platforms Android, Apple, Blackberry and Windows. It allows you to discover and enjoy new beers and bars near you, though am not sure if it has an option of giving you the route back home once you are drank. Maybe after reading this article you will develop this feature but remember the source of the idea once you become rich. Fingers crossed! The app also allows sharing of experiences, ratings and reviews and in addition has social media links which enables users to connect and interact. Brew manufacturing companies can use it to engage with their clients and evaluate customer trends.


Since you have an idea of what we are talking about let’s build a Phonegap App using WordPress backend.


This is a walk-through in which users can enter their credentials upon login, view and display WordPress Blog Posts. The procedure is flexible and can be used to create other apps of the same nature. WordPress, NodeJS and PhoneGap app are required, they are open source programs. NodeJS is a cross platform used for network applications, while WordPress is a web development application.


1. First we need to create REST APIs which are used to enable PhoneGap to communicate with WordPress. You may ask, what are REST APIs? REST abbreviates Representational State Transfer and in simple terms it is an architecture style used to provide guidelines for creation of web services that allows connection to networks and is also often used for mobile applications. While an Application Program Interface(API) is a set of tools, program instructions and protocols used to build and access software apps. Together Rest APIs can have various purposes including uploading , downloading data, exporting, among other purposes that interact with parse.


2. WordPress provides you the necessary tools to create REST APIs which can be used by any Hypertext Transfer Protocol(HTTP) client. REST APIs can be installed via a WordPress plugin or theme. A function called already_logged_in is executed if a user is logged in while making an Ajax request using PhoneGap and a session cookie is sent automatically to the server. Login function is executed if no user is logged in. A HTTP request is then sent and the REST API action is executed.


3. GET or POST REST APIs should be created using WordPress actions wp_ajax_ and wp_ajax_nopriv_ if the HTTP client making the request is logged in WordPress and a callback attached to wp_ajax_ and wp_ajax_nopriv_ are executed. I know all this jargon sounds very complicated, but try to follow and do it practically if possible, practice makes perfect.


4. Wondering what PhoneGap app is all about? It is an open source software used to develop cross mobile apps using HTML, CSS and JavaScript used in different mobile platforms. Desktop Builder tools are used, and three files are created for the directory structure, a www directory, HTML file and a JavaScript file.A User Interface is designed with JQuery using Content Delivery Network (CDN), which allows user interaction and displays graphics. CDN is a large distribution of servers used to provide content to end users. Two pages can be created, for user log in and to display posts under the HTML file and JavaScript log in function is called when the log-in button is clicked.


5. A front-end functionality is then coded under a JavaScript file, which contains three functions, login that obtains credentials for username and password, this information is sent to WordPress for authentication. If the authentication process is successful a session cookie is sent back by WordPress signifying the user has logged in. A fetch_and_display_posts function is then used to get and display the latest post and finally open_browser used to open post which is then displayed in a new browser window with PhoneGap InAppBrowser.


If you already have a WordPress website or you are planning to get one, AppPresser plugin can be used to integrate PhoneGap API to your website easily and it offers various features used to create mobile apps. It also allows integration of themes and plugins for both offline and online apps, when updating your website the content is automatically updated to your apps.


That’s it, use these techniques and tools build apps, customize, compile and sell them in different app stores after packaging, which people will then download and use. The ball is now in your court, start simple and with time it will be easy to build more complex apps.

16639 3 Views Today