SQLite on IOS (native app, not web app)

Hi,
Ok, I’ve finally taken the plunge on Voltbuilder for IOS app building (after having a lot of success on Android - THANKS TEAM!)
The support notes have talked me through the required steps and I’ve gone as far as Submitting an update to an app to App Store Connect!
The only issue I have now is the ‘SQLite Not Supported’ issue for IOS apps built on Voltbuilder.
I’ve tried to follow the guidance on here and have not had huge success yet, but have settled on this plugin (is it ok??)

cordova-sqlite-storage

It’s at this point that things seem to be getting a little light on support / guidance ( unless I’ve missed it!)

I changed my initial opening of a DB

Where I was using the original

DB = SqlOpenDatabase("mydbname.db","1.0",MyAppname")

I’ve changed it to

Javascript


var DB = null;

document.addEventListener('deviceready', function() {
  DB = window.sqlitePlugin.openDatabase({
    name: 'mydbname.db',
    location: 'default',
  });
});
  End Javascript

The app no longer throws the error, but nothing else seems to be happening.
Apologies if this is a stupid question, but what else do I need to change on my app code to use the plugin (rather than the original built in SQLite…?

Thanks,
Neil

I’m no expert in all the different Cordova SQLite plugins, but the one I use in my projects is

<plugin name="cordova-sqlite-evcore-extbuild-free" source="npm" />

Thanks for coming back to me.
Can I ask if you have to change your app code?
E.g. is there a requirement to initialize the plugin or change the usage of the queries in the app?

Not that I recall.

Thanks. Will give it another go tomorrow!

Hi, the following works for me (note slight differences in code,and apologies - I can’t seem to get the code snippet formatted with the triple ticks around it).

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
  try {
    if (window.SqlOpenDatabase) {
//  Create database if it does not exist
    DB = window.sqlitePlugin.openDatabase ({name: "plantcatalogue.db", iosDatabaseLocation: 'Documents'}, success, fail);
 } else {
    alert("SQLite NOT initialised");
  }
    sqlList = [];
    sqlList[0]=["CREATE TABLE .....;", success, fail];
    Sql(DB, sqlList);
}
catch(err) {
  alert(" Errror: " +  err.message);
    }
}

Only issue is I have to have to comment out device ready functions and substitute the browser open database statement when working on a browser for testing.

I use cordova-sqlite-storage.

Regards.

Tip : If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly.

You were using regular ticks, not back ticks.

Thank you. Didn’t realise it was back ticks :)!