Shahar
Shahar

Reputation: 541

Combine JQM, MVC and PhoneGap together

I have a site which uses microsoft mvc 3 on the server side, jQuery Mobile on the client side and I want to combine it with PhoneGap and produce executes for Android and iOS.

  1. Is it possible?

  2. How?

Thanks

Upvotes: 1

Views: 229

Answers (3)

jvlucic
jvlucic

Reputation: 81

Yes, it is possible.

If you must use Phonegap, there are a couple of things to do:

First, you must create a project corresponding to each platform , following these instructions. Once you do that, you basically copy all the client side code (js, html, css) to the www folder of your project. This is one of the reasons, the app could load faster, since it's reading its resources from the local filesystem, and not receiving them from an http connection each time.

Second, you must find a way to provide your server side data to your app. If you are already using REST services or RPC methods to populate your website, then that's done, but if not, you must start by building them, and then calling them from your client (through ajax calls from jQUery most likely), and then rendering them through javascript (you can use the multiple templating libraries out there or just plain javascript, I recommend the latter only if the UI updates are minimal).

As you can see, the second part requires quite a little bit more work. Especially if you haven't built web services before.

The other option ,which does not require phonega/cordova is to use an embedded webview. Then you wouldn't have to do anything. It would work similarly to a browser (Loading the remote URL of your site), with the added advantage of being inside and android/ios app, and you could add other views or communicate with the embedded webview using native code. If you are planning to load html files from the filesystem and not from your server, you would have to do the same thing you have to do with phonegap.

Upvotes: 1

Mat-Tap
Mat-Tap

Reputation: 755

It happened to me, if you have a web app depending on server code I would go with a WebView based app, and not a Cordova app.

It's really simple to create those webviews apps for Android or IPhone.

Here you have an example for building a webview based app on android

Here you have an example for building a webview based app on IOS

Hope it helps.

Upvotes: 1

Mat-Tap
Mat-Tap

Reputation: 755

If you want to reuse your site you'll need a webview that browses it.

Phonegap wouldn't be needed if you use this approach, but the application will not be as responsive as a native app, and the IPhone moderators may reject your app for that reason (it happened to me).

Another approach would be that you recreate your site as a pure Javascript application and only communicate with your servers to execute some REST Services. In this case Apache Cordova makes sense.

Upvotes: 0

Related Questions