Possible to share SQLite DB between PhoneGap and Native code? - iphone

I am writing a native iPhone and Android app using Sencha Touch inside Phonegap and my client is very keen for me to include Analytics.
The application needs to function happily offline so I need an analytics solution that can remember activity occurring while offline and updating the server once online again.
My thoughts are to store events from within the JS to a store that can be checked at a regular interval on the device and posted to the server.
My question is whether a SQLite DB could be used for this using the Phonegap API and whether this DB could then be accessed from the native code?
I suspect not and that the best option would be to write to a text file.
Any thoughts or suggestions gratefully received.

The solution to this seems to be to write a Phonegap Plugin that lets you call a method from inside Phonegap to a method in your native application.

Related

Phonegap for iphone development on Windows questino re native api

I've spent the day googling all the leads on developing iphone apps on Windows and apart from buying a mac the most suitable route seems to be Phonegap. I cannot find out whether Phonegap gives access to all the native functionality. For example I want to access and manipulate the address book contents. I also want to be able to send text messages programatically and intercept and examine incoming text messages. It would be helpful if someone could confirm whether this can be done with Phonegap.
My understanding is that Phonegap is based on webapps but I am assuming that an app developed with it can run offline for operations that dont require internet access.
Even using Phonegap you will still need access to a mac to actually build your iOS application. This is a restriction that Apple has in place, and to my knowledge there is no way around it.
Phonegap uses a UIWebView to display your application built using HTML, CSS, Javascript etc, but this does not mean that an Internet connection is required for the app to run (so offline apps are definitely possible).
With regards to Phonegap's functionality, details of the Phonegap API can be found on their website. Specific to your needs, I believe phonegap provides access to the device's address book through the contacts API:
http://docs.phonegap.com/en/2.3.0/cordova_contacts_contacts.md.html#Contacts
I don't think Phonegap provides the ability to send SMS messages itself, but many people have developed extensions to add extra functionality to their applications through plugins. The majority of Phonegap iOS plugins can found at the following GitHub repo. The plugin I think you require is the SMSComposer:
https://github.com/phonegap/phonegap-plugins/tree/master/iOS/SMSComposer

iPhone and Webapp sync through iCloud ??

just checking if its possible to sync iOS devices AND a web app through iCloud. Currently we've got an iOS app built, are looking at using iCloud for synching between all the devices and also want a web app component. iCloud would be great to use as the module to sync everything together.
Anyone know if it's possible ?
I have a similar requirement and have wondered about this too.
Unfortunately iCloud data doesn't seem to be accessible to a Web app. And if you found a hack around it, it would still be an unreliable solution as Apple could always make changes down the road that break your Web component, intentionally or not.
Edit: With CloudKit this is no longer true. It comes with a Javascript API for the explicit purpose of providing a web version of your app.
Sorry if I'm misunderstanding the question, but I was looking to add iCloud support to my web app recently and came across the official iCloud JS API. The promo text reads:
Keep your apps connected and up to date across iOS, OS X, and now on the web with CloudKit JS.
[emphasis added]
https://developer.apple.com/icloud/
It is really hard to determine what you mean.... If you are asking if you can implement iCloud in a web app, then I believe that the answer is 'no', since there is only an API for Objective-C for iCloud.
However, you might be able to embed your JS code inside of a native wrapper and write some native code for working with iCloud. However, that may or may not be an option depending on your particular situation.
Edited for spelling.
You could possibly do this, but only if
You where running your own server
The server was running on the iOS platform
You where able to create software in Objective-C for that server
You could then potentially write a server application, that could be used to connect to the iCloud API, then return the calls back to the end user as Json messages that could be consumed, perhaps by some html interface.

Can PhoneGap apps use server pages to load on it?

I am trying to do web apps using PhoneGap framework for iOS. I need to know whether PhoneGap loads page from server or not, I mean , can I use server side scripting language like php, pyhon, etc?
And if I used those scripting language, can I use phone native feature like camera?
Also for data storage there may be feature, I heard opendatabase can be used for online / offline database. Please anyone help me to figure out these things.
Waiting for good answer.
Thanks
Server side scripts cannot be loaded from within the app, however you can certainly call out to PHP, Python, etc running on a server from the app using AJAX, XHR, etc.
I gave an example in the question below:
How can get value in phonegap which is returned by php class?

How to use native sqlite in ios' webview?

I just want to develop an ios app based on webview. The offline storage must be used. I know that html5 offline storage is supported by webview. But I just want to use a native sqlite file(not the one embedded in webkit) just like other native ios app. So could anyone please give me some clues?
Are you implementing the database via javascript? If so check out this great free eBook on building iPhone apps. The chapter about Client-Side Database should give you a running start.
http://ofps.oreilly.com/titles/9780596805784/ch05.html#ch05_id35933084
regards
Andrew
webSQL is available in UIWebViews.
However, if you're using Cordova the convention is to use the SQLite plugin. GIYF.
I personally like using web storage wrappers for this. Lawnchair.js and persistence.js were earlier wrapper solutions, but I like using Mozilla's localForage the most. It makes storing any kinda JS primitive/object/blob really easy.
localForage is just a wrapper over localStorage, webSQL, and SQLite. It has a really simple API and will choose the best web db for you based on what you wanted to store (was it serializable: localStorage. was it a [file Object] from an HTML input: webSQL). Your project can be a Cordova project or whatever. Don't matta. It'll work.

How to Use PHP in IPhone Applications

I need to create an iPhone application using Facebook.
The facebook FBConnect API supports FQL which is similar to SQL Queries.
I would be able to create the application easily using PHP as compared to Objective-C.
So if there is any way to create an iPhone application using PHP please reply to me.
Thanks.
Well, if you are developing something for jailbroken devices , yes it is possible to use PHP (you have to install it first from Cydia).Also note that you should implement a SQLite database if your app/script needs database functionality (you can't run a MySQL server natively on iPhone ATM).
But, as pekka mentioned, this is a really bad idea, because you must set up first a lighttpd web server on iPhone (not really comfortable), or if you're planing to implement a CLI PHP script, you should first launch it (using some C functions like pipe(), dup2(), fork(), execl()) and then parse its output inside your -not-so-Objective-C- iPhone app.
So think it again...