How to run a PhoneGap app with Sqlite in Ripple?

cordova, phonegap-plugins, ripple, sqlite

Solution

Phonegap plugins won't work with Ripple because the idea of a Phonegap plugin is that it provides a Javascript interface in order to execute native code. That means, in the case of Android, the Javascript will invoke native Java code and in the case of iOS, the Javascript will invoke native Objective-C.

Ripple is purely Javascript-based, so the Javascript part of the plugin has nothing to interface with.

In the case of the SQLitePlugin, for example, calling `SQLitePlugin.close()` results in the call:

cordova.exec(null, null, "SQLitePlugin", "close", [this.dbname]);

where `SQLitePlugin` is the native class name and `close` is the native function name.

If you want to use the same storage API across Android, iOS and Ripple, maybe consider using lawnchair with appropriate adapters.

As for the issues with Ripple and Phonegap 2.7.0/2.9.0, Ripple has not quite caught up with Phonegap, so you will get these popups and error messages in the console, but that will not stop your Phonegap app (without native plugins) running in Ripple. You can convince yourself of this with a simple test case like:

document.addEventListener("deviceready", function(){
  alert("I'm alive");
});

But the answer is, yes, you do need to include cordova.js in order for it to work at all in Ripple.

Problem

I have a phongap app with a sqlite plugin that runs in both android and iphone. When I try to run it in Ripple i get several errors depending on the inclusion of the cordova version and device I use. Non of them are working at all. In some comments in stackoverflow i've seen people running sqlite in phonegap under ripple. I'm using the PG-SQLitePlugin-Android plugin in my project, which it acually only supports Phonegap 2.7.0+. I've found that i can force Ripple to use 2.7.0 by calling it : file://localhost/Users/----/----/----/www/index.html?enableripple=cordova-2.7.0 Ripple actually loads great after enabling access to file system through chrome. When i include cordova-2.7.0.js in my script The index.html pops me a pop up with the following text : gap:["Device","getDeviceInfo","Device119187522"] that i can accept or cancel, then 2 more dialogs appeare, if I accept it gets hanged. the js console shows that cordova 2.7.0 is really running : Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. cordova-2.7.0.js:906 deviceready is not fired When i include cordova-2.9.0.js in my script It happens the same as 2.7 Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. cordova-2.7.0.js:906 but this time I get this other errors Failed to load resource file://localhost/Users/laullobetpayas/-------/---/------/www/cordova/cordova_plugins.json Failed to load resource file://localhost/Users/-------/---/------/www/cordova/cordova_plugins.js deviceready is not fired When I don't include any cordova.js in my script SQLitePlugin.js:31 Uncaught ReferenceError: cordova is not defined SQLitePlugin.js:34 - Am I using the proper plugin ? - which is the propper version of cordova / device tu run with the plugin and ripple ? - Do i have to include the cordova.js in my project Hel will be very apreciated, it's for a long time that I'm trying to solve this. Thank you in advanced.

Original source