Does it make sense to use 'Core Data' for storage in a Phonegap-based hybrid iPhone/iPad app? Our app is mainly going to run inside a UIWebView, but the data-storage component is going to be central to the working of the app. I know Mobile Safari has offline storage capability which can be used via PhoneGap, but we already have an in-house data-storage solution build on top of Core Data that we would like to leverage.
Thanks Kapil
You could create a PhoneGap plug-in, which is a custom extension to the PhoneGap API. It includes a bit of native code that does some native-specific functionality, as well as a JavaScript interface that then exposes this functionality to you, the PhoneGap developer. By definition, a plug-in is platform-specific!
In your case, you would create a plug-in that exposes the Core Data API to the PhoneGap browser instance. Presumably, since you already have a bunch of the Core Data-based code written, the majority of the work is done. You simply have to write the JavaScript wrapper around it and form your native code so that it fits into the plugin pattern.
A good place to start would be Jesse's blog post about them; note that these are specifically for iPhone:
http://blogs.nitobi.com/jesse/2010/04/01/iphonegap-plugs/
Here are some examples of existing PhoneGap plugins, how to use them, and links within to the source code to see how they were built:
https://github.com/phonegap/phonegap-plugins
http://blogs.nitobi.com/shazron/2010/07/12/phonegap-iads-plugin/
http://blog.urbanairship.com/blog/2010/06/09/phonegap-push/
Here's one by fellow StackOverflower and answerer above, Aaron :)
http://blog.clearlyinnovative.com/post/1097750723/phonegap-plugin-for-downloading-url
Hope that helps!
i think if you have already made that investment, why not just write a native application?
you are going to have to do some "interesting" things to get the PhoneGap application to integrate with your CoreData solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With