1

I'm new to Phonegap/Cordova and trying to get my head round it.

I have a responsive web app built with knockout.js that I want to wrap as an Android app using Cordova. I'd like to keep the vast majority of the code hosted live on my site and only have the Android-specific stuff in the app itself, if possible.

For example, I'd like to handle the Android 'back' button properly so it can be used to navigate backwards and then background the app without it being killed (it plays music so I need it to stay alive). This answer, for example, gives a solution but requires a custom plug in and event handler.

I can open my page using super.loadUrl("www.mysite.com") but after that it's a dead end.

Is it possible to create a hybrid web app so that the local and remote scripts can interact, and if so, what's the best way to structure it?

Community
  • 1
  • 1
Will Jenkins
  • 9,507
  • 1
  • 27
  • 46

1 Answers1

1

I've found a way to do it so thought I should put it here for others who are stumped like I was.

The trick is to load the remote content into an iframe within the 'standard' index.html page that is generated by Cordova. Then, use a library like porthole.js to communicate between cordova and the iframe. It takes a bit of setting up but it works.

Will Jenkins
  • 9,507
  • 1
  • 27
  • 46