Hi guys,
I've been trying to solve this problem for several days and I have not figured it out yet. The problem lies in the fact that when I send a notification out on my acs dashboard, I only get one api call on my backend. Now, I have a few people using this app (colleagues) and they should be sending these api calls when I send them a notification. That doesn't happen. I've tested this on two phones and only one responds with the api call when I send out a silent push notification. Every morning I have a scheduled silent push, yet only one phone fires at a time from a pool of about 6 phones. Anybody experience this?
Now here is my code for monitoring silent push notifications
// Monitor silent push notifications Ti.App.iOS.addEventListener('silentpush', function(e) { Ti.API.info("silentpush: " + JSON.stringify(e)); notificationModel.processPush(e); Ti.App.iOS.endBackgroundHandler(e.handlerId); });Here is my code for processing that push
extendModel: function(Model) { _.extend(Model.prototype, { processPush: function(payload) { Ti.API.info("</\> Processing Push </\>"); if(OS_ANDROID) { payload = JSON.parse(payload.payload); if (payload.exit == "1") { var user = Alloy.createModel('user_model'); user.exitGeofences(); } if (payload.update == "1") { var approvedcallback = function() { var geofenceModel = Alloy.createModel('geofence_model'); geofenceModel.updateGeofences(); }; var noschedulecallback = function() { // TODO Determine what actions to take if a user no longer has a set schedule. }; Ti.API.info("</\> Push says to update </\>"); var schedule = Alloy.createModel('schedule_model'); schedule.getSchedule(null, approvedcallback, noschedulecallback); } } else { //var data = JSON.parse(payload); if (payload.exit == "1") { var user = Alloy.createModel('user_model'); user.exitGeofences(); } if (payload.update == "1") { var approvedcallback = function() { var geofenceModel = Alloy.createModel('geofence_model'); geofenceModel.updateGeofences(); }; Ti.API.info("</\> Push says to update </\>"); var schedule = Alloy.createModel('schedule_model'); schedule.getSchedule(null, approvedcallback, noschedulecallback); } } },When I fire my exitGeofences function above I do this code.
var client = Titanium.Network.createHTTPClient({ onload : function(e){ if (this.status == 200) { var response = JSON.parse(this.responseText); Ti.API.info(JSON.stringify(this.responseText)); success(); } else { Ti.API.info('status: ' + this.status + ' error: ' + e.error); } }, onerror : function(e) { Ti.API.info('error: ' + e.error); error(); }, timeout : Alloy.Globals.networkTimeout, validatesSecureCertificate: false }); client.open("POST", Alloy.CFG.apiBaseUrl + "user/exitGeofences"); Ti.API.info("POST:" + Alloy.CFG.apiBaseUrl + "user/exitGeofences"); client.setRequestHeader('X-API-KEY', Titanium.App.Properties.getString('prop_apikey')); client.send();I have the backend setup to handle that api call. It just doesn't fire more then once when I call it on a silent notification push from the ACS dashboard. I am at my wits end with this and help would be appreciated.