I have written a simplistic chat application using Rails 3 and JQuery Mobile, you can have a look at the prototype here : http://budz.vdsites.com
It's usefelness however is pretty limited as a mere web app, and I'm looking to include some native mobile capabilities such as notifications, picture uploading ( through the gallery or the camera ), contacts fetching and maybe more to come after that. I am also planning to deploy a similar enhanced client for desktops, using the same front end for both.
One important requirement is to be able to write the minimal required code to enable those abilities, as I could support more than a platform set and then maintaining every code base will become tedious.
After some research it turns out my best bet would be a PhoneGap based chromeless native app, with just enough functionality in the phone-side to enable those extra functionalities. For this, the InAppBrowser widget seems to be perfectly adapted to the job.
However, looking into it's API further, it seems that there's next to no facility to enable a basic communication going between the native application and the web app, except the basic load related events which are useless to me unless I hack my application massively to trigger these events ( and it looks pretty bogus to do so ).
Ultimately, I would like to be able to listen to custom events on the PhoneGap side, and trigger them from the webapp.
I came up with some leads to achieve the required functionality :
- I could create a DOM element to use it's properties as a medium between the native side and the web app - But there doesn't seem to be a way to access the DOM from outside it's container.
- I can listen to some specific endpoints in my webapp from phoneGap, outside the inAppBrowser and trigger native functionality based on the server response - This definitely works, but it implies I have to write different listening code for other platforms and thus breaks slightly my minimal coding requirement.
So here's my questions :
- Is there a way to achieve the behaviour I want ( Event dispatching ) using PhoneGap ?
- What do you think about my two suggested approaches ?
- Should I look for another platform ? What do you suggest ?
- What's the community take on this ? How do you handle such cases ?
Thank you for any insights you can provide !