How to launch PhoneGap application with Sqlite in Ripple?

I have a phongap application with sqlite plugin that works on both Android and iphone. When I try to run it in Ripple, I get a few errors depending on the inclusion of the cordova version and the device I am using. None of them work at all. In some comments on stackoverflow, I saw how people working with sqlite in a telephone bundle throbbed.

I use the PG-SQLitePlugin-Android plugin in my project, which it usually only supports Phonegap 2.7.0 +.

I 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 really loads fine after enabling file system access via chrome.

When I include cordova-2.7.0.js in my script

A pop-up message appears in index.html with the following text:

space: ["Device", "getDeviceInfo", "Device119187522"]

that I can accept or cancel, then two more dialogs will appear if I agree to be hanged.

js console shows that cordova 2.7.0 really works:

Return to PROMPT mode since _cordovaNative is missing. Only expected for Android 3.2 and below. Cordova-2.7.0.js: 906

deviceready not starting

When I include cordova-2.9.0.js in my script

This happens the same way as 2.7

Return to PROMPT mode since _cordovaNative is missing. Only expected for Android 3.2 and below. Cordova-2.7.0.js: 906

but this time I get 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 not starting

If in my script

does not contain any cord .js,

SQLitePlugin.js: 31 Uncaught ReferenceError: cordova not defined SQLitePlugin.js: 34

  • Am I using the correct plugin?
  • which is the version of the tu / ku device with plugin and ripple?
  • Is it necessary to include the cordova.js project in the project.

Hel will really like it, he has been trying to solve this problem for a long time. Thank you for your promotion.

+4
source share
3 answers

Phonegap plugins will not work with Ripple because the idea of ​​the Phonegap plugin is that it provides a Javascript interface for executing native code. This means that in the case of Android, Javascript will refer to its own Java code, and in the case of iOS, Javascript will refer to the native Objective-C.

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

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

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

where SQLitePlugin is the name of the native class, and close is the name of the built-in function.

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

Regarding issues with Ripple and Phonegap 2.7.0 / 2.9.0, Ripple didn’t quite catch up with Phonegap, so you will get these pop-ups and error messages in the console, but it won’t stop your Phonegap application (without built-in plugins) running in Ripple . You can verify this with a simple test case, for example:

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

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

+6
source

Cordova-SQLitePlugin is a replacement for the HTML5 SQL API, so when you start inside Ripple you do not need to call the Cordova layer, you can simply replace the sqlitePlugin.openDatabase () calls with window.openDatabase (). I have not tested this with Ripple yet, but it should work. There are some database size restrictions, but this is probably all you need for testing.

There are several ways to check if your inner Cordoba. You can create a pad for the openDatabase () method based on testing Cordoba at application startup.

+2
source

Since your main goal is to really do a quick SQLite test with Cordova (and not specifically use Ripple), I would like to suggest a new alternative to using Ripple.

I wrote the Sencha Touch Live application, which you can use to quickly develop Cordova / HTML5 applications, allowing you to edit and debug Live HTML / JS / CSS code on your mobile device by simply updating the files on your development computer so you can skip most of the time recompiling / redeploying / restarting the debugger time. It has many other interesting features. I myself use it to test SQLite applications instead of Ripple or Weinre

It is based on code from the Adobe PhoneGap Developer application, so the main code is well tested. It has been widely adapted and configured for the Sench Touch platform, although it should also work for jQuery Mobile or any infrastructure that puts HTML5 code in the phonegap/www or cordova/www folder. Just start the server in the PhoneGap or Cordova project folder.

To test your SQL logic and controller, I recommend using the Geny Motion emulator with Android 4.4.x KitKat. Launch the latest version of Chrome on your desktop, and as soon as you get your application working on an emulator or real device, open chrome://inspect , and now you can use the full Chrome debugger in your remote device application. You can also use the latest version of Safari to test the OSX / iPhone simulator.

You can watch the demo here (starts at 5 minutes). Yes! This requires a more polished video with fewer echoes, but you get the idea:

0
source

Source: https://habr.com/ru/post/1497066/


All Articles