Search code examples
jquerymysqljsoncordovaphonegap-cli

Phonegap Cross-Platflorm App getting Exernal Data


This is my first hybrid app and i am using CLI phonegap to develop it on a windows computer. i would like the app to be compatible with the latest versions of ios and android and i wouldn't mind if it was compatible with old versions of android as i know some phones can't upgrade to the latest version.

i need to develop a cross-platform app. The app will have multiple pages where different pages load different data from an external server. The app has a navigation drawer as well so that these different pages can be accessed. I'm not sure what the best way is to do this.

I can display data on the index page by making a call to a file on the external server which converts the data to json. i can do this for one page only and am not sure how to do it when i select a different page from the navigation drawer. because when i select a different page nothing loads. I would prefer to have the pages saved in dfferent files as there will be alot of pages and it will be too much if added all in the index page.

Please could you help as i have spent days trying to figure out the best way to set up my app.


Solution

  • @AN11, it appears you have knowledge on how to do what you want to accomplish. However, your biggest issue is "how to load external data".

    For the external sever, the most typical way to load data from a REST API. Most can return (or are capable of returning) a JSON data structure. Many commercial services, such as firebase, strongloop, and parse.com (recently Facebook made open source), run as a MBaaS (Mobile Backend As A Service) and are free (with bandwidth constrained). You can also find a lot of open source solutions for PHP, Rudy, PERL and (of course) node.js.

    On the Cordova/Phonegap end you will need to add the whitelist plugin to the config.xml and the associated CSP (Content Security Policy) to the HTML pages. However, in your case you might want to go with an SPA, such as ionic. To apply this whitelist system I will suggest you read this FAQ: HOW TO apply the Cordova/Phonegap the whitelist system

    Also worth noting, you can use a different architectural solution by loading the pages with the file-transfer plugin.

    Lastly, I would suggest you if you have further question, you should ask at the Google Group of Cordova/Phonegap - Best of Luck