This is a migrated thread and some comments may be shown as answers.

iOS WebSQL not working

2 Answers 168 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Delphi
Top achievements
Rank 1
Delphi asked on 18 Nov 2015, 09:17 PM

 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 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 23 Nov 2015, 10:59 AM
Hello,

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 

Regards,
Tsvetina
Telerik
 

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

 
0
Delphi
Top achievements
Rank 1
answered on 23 Nov 2015, 08:21 PM
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.
Tags
General Discussion
Asked by
Delphi
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Delphi
Top achievements
Rank 1
Share this question
or