PhoneGap or in it’s new name Cordova is a set of device APIs that allow a mobile App developer to access native device function such as the camera or accelerometer from JavaScript. Combined with a UI framework such as jQuery Mobile or Dojo Mobile, this allows a smartphone app to be developed with just HTML, CSS, and JavaScript (cross platform). Cordova is available for the following platforms: iOS, Android, Blackberry, Windows Phone, Palm WebOS, Bada, and Symbian.
In general, Cordova is a really clever way to build your Apps for more than just one operating-system, and if you are intending to write an App that will eventually run on multiply operating-systems, Cordova can be a really good solution in order not to get your hands dirty with each operating-system’s native code. This is an option you should really consider, after you decided what is it you exactly need in your App and what is the best way to implement it.
Now of course not everything can be done on Cordova code level, which is why Cordova has created a wide range of different plugins in order to reach further into the platform and to be able to use stuff like: devices camera, accelerometer, alert dialogs, file system etc. And although Cordova tries to provide a wide range of plugins, and what is not provided by Cordova can be always found on Google.
Sometimes it does not meet your needs, thus the solution will be to build your own plugin. The plugin needs be implemented on the platforms individually, which contradicts the fact that you didn’t want to handle the native code in the first place.
Here comes the first problem. For our purposes we needed to connect the Parse user linked to the Facebook user. Using the Parse Facebook login on JavaScript SDK or iOS SDK alone this a very simple thing to do, but through Cordova thats another story. Initializing Parse Facebook SDK through JavaScript isn’t possible when running on a device because Facebook needs to see from which domain are we coming and if it’s listed. On a phone we don’t have an explicit domain, so naturally the initialization through Parse in the Javascript will not work, hence we must find another way.
We go back to the plugin option. Cordova offers a Facebook login plugin, but since we are using Parse, we have to establish a link between the Parse user and the Facebook user, an action which requires a custom plugin to create the connection. Once you create the Parse connection on the native side of the App the Parse functions on the Cordova side won’t have the user details, that is to say that when you want to call for example a Parse Cloud function that – let’s assume for the sake of the argument – gets all time high scores and needs the user in order to get the user’s position, you will have to implement it on the native side as well.
In the end, this creates a situation where each action that needs to be done with the user needs to call the plugin and to be implemented in the native side of the App, and if you are to create an app that it’s whole meaning is to run around Parse and Facebook, then the amount of the native code you have to implement would make to start to wonder if the Cordova solution is really the solution you are looking for.
For a lot of other things, a HTML5 app with Cordova would probably be the best way to go, but if you are using the link between the Parse and the Facebook user, and you find yourself already in a situation where you have to implement the plugin on all the platforms you need it to work with, it makes more sense to stay on the native side and to create the App for each platform individually. What is your opinion about Cordova, Parse and Facebook?