Problem
* [Titanium.App.iOS.LocalNotification](
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.App.iOS.LocalNotification-object) notifications scheduled from a background process last for exactly 40 seconds
* Firing an event from a background process causing app.js to schedule a local notification does not solve the problem. In this case the notification lasts for exactly 30 seconds
Note that Local notifications scheduled directly from
app.js
work as expected (last forever)
Test case
Ti.Geolocation.purpose = 'Geolocation';
Ti.App.service = Ti.App.iOS.registerBackgroundService({url: 'service.js'});
var fired = false;
function location(e) {
if (e.error) { return false; };
if (fired === false) {
fired = true;
var notification = Ti.App.iOS.scheduleLocalNotification({
alertBody:"Bananas was put in background",
alertAction:"Re-Launch!",
userInfo:{"hello":"world"},
date:new Date(new Date().getTime() + 1000) // 1 second after backgrounding
});
Ti.Geolocation.removeEventListener('location', location);
};
return;
};
Ti.Geolocation.addEventListener('location', location);
Ti.App.service.addEventListener('stop', function() {
Ti.Geolocation.removeEventListener('location', location);
});
Discussions
Helpdesk: [APP-564871](
http://support.appcelerator.com/tickets/APP-564871)
Thanks for raising this ticket. Please check the environment field against the [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist), and add any missing information. I will mark this resolved for now. Please reopen it once it is complete, and I will move it to the main project. Cheers
I've updated the field with relevant information.
I think the main issue is this: "Based on my understanding of the titanium source when you create a new notification they return a TiAppiOSLocalNotificationProxy....which you cannot really do anything with such as save it to a property or anything. However, as soon as the proxy loses scope and it gets cleared up the dealloc will cause the notification to be cancelled. This is one reason in the KitchenSink example the notifications are included in the background example, because with their implementation if you closed the app and still didn't have a variable holding on to it....it would cancel the notification. This is not a requirement in normal iOS but with the Titanium implementation you have to hold on to the variable."
Resolving ticket as Invalid as there is now a new version of Kitchen Sink available and we no longer support the version which relates to this ticket.