I am developing an application in which I occupy the Cordova Sqlite plugin.
I have a problem in the Ios platform when the device does not have internet, every time I enter the application it stops working, in the logs I receive absolutely nothing. No error, only the application stops working.
Within ionicPlatform.ready
I declare:
var db = null;
if (ionic.Platform.isIOS() || ionic.Platform.isIPad()) {
var db = $cordovaSQLite.openDB({ name: 'mydb.db', location: 'default' });
} else {
var db = window.openDatabase("mydb.db", '1.0', 'My DB', 1024 * 1024 * 100);
}
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS ranking (ranking_id integer primary key, ranking_titulo text, ranking_anio text, ranking_categoria text, ranking_detalle text)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS ranking_jugador (ranking_jugador_categoria text, ranking_jugador_ciudadNombre text, ranking_jugador_email text, ranking_jugador_fono text, ranking_jugador_foto text, ranking_jugador_id integer, ranking_jugador_nombre text, ranking_jugador_paisNombre text, ranking_jugador_posicion integer, ranking_jugador_puntaje integer, ranking_ranking_id integer)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS jugadores (apellidos text, categoria text, ciudad text, email text, fono text, foto text, id integer primary key, nombres text, pais text, rut text)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS entrenadores (apellidos text, ciudad text, email text, fono text, foto text, id integer primary key, nombres text, pais text)")
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS avisos (id integer primary key, aviso_creador_id integer, aviso_creador_nombres text, aviso_creador_apellidos text, aviso_creador_foto text, aviso_creador_fono text, aviso_creador_email text ,aviso_descripcion text, aviso_fecha_publicacion text, aviso_moneda text, aviso_precio text, aviso_tipo integer, aviso_titulo text, aviso_visible integer, aviso_imagen_principal text, aviso_visto integer)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS avisos_imagen (id integer primary key, imagen_aviso text, imagen_aviso_id integer)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS noticias (id integer primary key, titulo text, descripcion text, imagen text, publicada integer, vigente integer, user_id integer, user_nombres text, user_apellidos text, fecha_publicacion text)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS torneos (torneo_id integer primary key, torneo_nombre text, torneo_descripcion text, torneo_inicio integer, torneo_termino integer, torneo_afiche text, torneo_coordinador_id integer, torneo_coordinador_nombres text, torneo_coordinador_apellidos text, torneo_coordinador_imagen text, dias integer, estado integer)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS fechas (fecha_id integer primary key, fecha_id_torneo integer, fecha_nombre text, fecha_club_nombre text, fecha_valor_inscripcion integer, fecha_inscripcion_inicio text, fecha_inscripcion_termino text, fecha_inicio text, fecha_termino text, fecha_categorias text, fecha_afiche text, fecha_nombre_coordinador text, fecha_apellido_coordinador text, fecha_imagen_coordinador text, fecha_email_coordinador text, fecha_fono_coordinador text, fecha_pais_coordinador text, fecha_ciudad_coordinador text, fecha_dias_inscripcion integer, fecha_resultado_pdf text, fecha_programacion_pdf text)");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS categorias (nombre_categoria text, categoria_codigo text primary key, vigente int)");
But when you return the internet to the device everything works without any kind of problem.
EDITING
Check logs and I get this when I do not have a connection.
2017-04-04 11:33:26.875810 MyApp[479:44694] -[SQLitePlugin pluginInitialize] [Line 33] Initializing SQLitePlugin
2017-04-04 11:33:26.876087 MyApp[479:44694] -[SQLitePlugin pluginInitialize] [Line 44] Detected docs path: /var/mobile/Containers/Data/Application/D1DF9229-D8EA-48C6-A50C-7E3BA5863484/Documents
2017-04-04 11:33:26.876206 MyApp[479:44694] -[SQLitePlugin pluginInitialize] [Line 48] Detected Library path: /var/mobile/Containers/Data/Application/D1DF9229-D8EA-48C6-A50C-7E3BA5863484/Library
2017-04-04 11:33:26.876299 MyApp[479:44694] -[SQLitePlugin pluginInitialize] [Line 55] no cloud sync at path: /var/mobile/Containers/Data/Application/D1DF9229-D8EA-48C6-A50C-7E3BA5863484/Library/LocalDatabase
2017-04-04 11:33:26.876920 MyApp[479:44694] OPEN database: mydb.db
2017-04-04 11:33:26.877012 MyApp[479:44694] new transaction is waiting for open operation
2017-04-04 11:33:26.877092 MyApp[479:44694] new transaction is waiting for open operation
2017-04-04 11:33:26.877152 MyApp[479:44694] new transaction is waiting for open operation