Hi guys,
Currently i am developing an android app that can received notifications from the Urban Airship provider. I'm trying to store the notifications message in the SQLite Database to be use as a logs. But, I encounter problems as stated below.
Sending multiple message without opening it from android notification window. 1. When my app is running on the background which means my app is closed and i tap on the android notification window message, it only save 1 message. (Refer SS_1_in_bground & SS_2_in_bground)
 
- When i run the app and multiple different notifications received, my app can display list of notifications. But, it contains a duplicate message. (Refer SS_3_in_app & SS_4_in_app)
 
The list of notifications can be display correctly when i open my window through the app notifications directly. (Refer SS_5_noti_log & SS_6_noti_log)
 
Source Codes:
function eventCallback(e) { var key = ''; key = e.payload; var msg = ''; msg = e.message; var clik = e.clicked; //showOnAppClick = true; //db.addNoti(msg,key); Ti.API.info('clik: '+clik); Ti.API.info('Today: '+Date()); //alert("KEY MASOK: "+key); var sp1 = key.split('{').join(''); var sp2 = sp1.split('=').join(''); var keySp = sp2.split('}').join(''); var charCode = keySp.charCodeAt(0); var char1 = String.fromCharCode(charCode); //alert("char1 "+char1); var not = ""; not = db.getNoti(); if (clik == false && clik != true) { if (char1 == 1) { //Calling query for insert/update existing Id/Key - for HotPick only if ((not == null)) { db.addNoti(msg, key); } else if (not != null) { for (var i = 0; i < not.length; i++) { var keyDb = not[i].Key; //keyDb.split('{=}').join(''); var sp1 = keyDb.split('{').join(''); var sp2 = sp1.split('=').join(''); var keySp = sp2.split('}').join(''); var charCode = keySp.charCodeAt(0); var char1 = String.fromCharCode(charCode); var result = ''; if ((char1 == 1)){ db.updateNoti(msg, key); return 1; }else{ //alert("tak"); db.addNoti(msg, key); return 0; } } db.updateNoti(msg, key); } } } else { db.addNoti(msg, key); } } else { new notiSwitch().open(); //alert("Not Same"); } } function eventSuccess(e) { Ti.API.info('Received device token: ' + e.deviceToken); // labelAPID.text = e.deviceToken; } function eventError(e) { Ti.API.info('Error:' + e.error); var alert = Ti.UI.createAlertDialog({ title : 'Error', message : e.error }); alert.show(); } UrbanAirship.addEventListener(UrbanAirship.EVENT_URBAN_AIRSHIP_CALLBACK, eventCallback); UrbanAirship.addEventListener(UrbanAirship.EVENT_URBAN_AIRSHIP_SUCCESS, eventSuccess); UrbanAirship.addEventListener(UrbanAirship.EVENT_URBAN_AIRSHIP_ERROR, eventError);Anybody also encounter the same problem? Any help is appreciated. Thank you guys.
Application type: mobile
Titanium SDK: 3.1.1 (06/15/13 16:09 f7592c1)
Platform & version: Android 4.2.2
Device: MSI Primo 8 series
Host Operating System: Windows 7 Professional
Titanium Studio: 3.1.3.201309132423