iOS WebSQL not working

Thread is closed for posting
3 posts, 0 answers
  1. Delphi
    Delphi avatar
    11 posts
    Member since:
    Mar 2015

    Posted 18 Nov 2015 Link to this post

     The following code works in the simulator and on an Android tablet, but is not working on an iPhone. Does anyone have any suggestions?

    var dbsql = openDatabase('testWebSQL', '1.0', 'Test Web SQL DB', 2 * 1024 * 1024);
    dbsql.transaction(function (tx) {
        tx.executeSql('CREATE TABLE IF NOT EXISTS Customers (ssn unique, name)');
    function getWebSQLCustomers() {
        dbsql.transaction(function (tx) {
            tx.executeSql('SELECT * FROM Customers', [], function(tx, results) {
                var len = results.rows.length;
                var i;
                for (i = 0; i < len; i++)
                    alert('WebSQL: ' + results.rows.item(i).name);
            }, null);
            tx.executeSql('INSERT INTO Customers (ssn, name) VALUES (?, ?)', ['123', 'Bill']);
    // getWebSQLCustomers() is called by a button click event and after the first click shows an alert on Android but not on an iPhone

  2. Tsvetina
    Tsvetina avatar
    2329 posts

    Posted 23 Nov 2015 Link to this post


    Have you tried deploying the app via cable connection on an iOS device using a Development provisioning profile and certificate? With such deployment, you will be able to see any errors that occur during execution in the Output window (Windows client, VS extension). There is probably an error occurring and seeing the error message will help you identify it.

    Additionally, you can consider using the SQLite plugin, which shares similar syntax to WebSQL, and is tested to work on all supported platforms:
    SQLite Cordova plugin 


    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

  3. Delphi
    Delphi avatar
    11 posts
    Member since:
    Mar 2015

    Posted 23 Nov 2015 Link to this post

    We have used the cable connection and the problem was that the openDatabase code needs to be in onDeviceReady for it to work on an iPhone.
Back to Top