When there is the callback of the module I can't store something on the database.
When I receive the push notification I get this error:
Creating [object TiDatabase] in a different context than the calling function.
There is the code:
pushnotifications.pushNotificationsRegister({
"pw_appid": "XXXXX-XXXXX",
"gcm_projectid": "XXXXXXXXXXX",
success:function(e)
{
},
error:function(e)
{
},
callback:function(e) // called when a push notification is received
{
//IF I PRINT WITH Ti.API.info OR WITH THE ALERT IT WORKS
//Ti.API.info('JS message event: ' + JSON.stringify(e.data));
//alert(e.data.aps.alert);
if(e.data.u){
var arrayStringa=e.data.aps.alert.split("- ");
var sottostringa=arrayStringa[1].split(": ");
var titolo=sottostringa[0];
var testo= sottostringa[1];
var db = Titanium.Database.open('database');
db.execute('INSERT INTO notifiche (id,titolo,testo,categoria,gestore_id,visualizzato) VALUES ( "' + e.data.p + '","' + titolo + '","' + testo + '", "' + temp.cat + '", "' + temp.id + '",0)');
db.close();
}
},
timeout: 500
});
pushnotifications.setTags({ "channel" : channel});
When there is the callback of the module I can't store something on the database.
When I receive the push notification I get this error: Creating [object TiDatabase] in a different context than the calling function.
There is the code: