Create a mobile App with phonegap and backendless
In this article we are going to create mobile application with phonegap and Backendless. Backendless is BaaS platform it provides backend as a service and phonegap is technology that help you build hybrid application with HTML, CSS and JavaScript.
Prerequisites Phonegap must be installed on your computer if you don’t have phonegap you can install it using instruction in http://docs.phonegap.com/getting-started/1-install-phonegap/desktop/
Lets start with creating a phonegap project I am doing it using CLI to create phonegap project we need to write following commands
phonegap -g create nameofapp
Once we have created project below is directory structure of the project
Now we have created the project now lets see how we integrate backendless with this project
Follow the steps below
- Go to the backendless website https://backendless.com/
- If you already have account click login other wise register
3. Once you registered or logged in now you will see a dashboard as shown below
The sidebar where all functionalities that backendless provide are available we are going to use third option form this side bar which is database
4. Click on 3rd item in sidebar you will see dashboard as shown below
You can add table from the dashboard or you can also do it with coding that we will also see here
4. Once we have logged now we will download project template from top of the page
5. We will select JS javascript and click next
6. We will select HTML-JS and click download and project will be download that you will extract it
7. When you will extract downloaded zip you will see a folder created with the name of app you will go to src->js and copy backendless.js and paste it to www->js in your phonegap project
8. Now create a main.js file in www->js where we can code the logic for application
8. Now lets code main.js to create a table and add something in that table
first we will initialize app id and key which will be provided to us on dashboard the we initialize app with initApp method that takes two parameter then we have created a method addObject in which we have created a table namely TestTable and then we have saved an object with two properties name and mail and we have used promise and catch to show any error
This is simple index.html we have added backendless.js and main.js and created a button that invokes method addObject when it is clicked
For more operation on backendless follow the documentation https://backendless.com/docs/js/
I will also write next tutorial on how to apply CRUD operation with backendless database