Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6923] iOS: App.iOS - LocalNotification scheduled from a background process dismiss after 40 seconds

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-05-02T22:04:11.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterJeevan Takhar
AssigneeIngo Muschenetz
Created2011-11-08T16:14:30.000+0000
Updated2017-05-02T22:04:11.000+0000

Description

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)

Comments

  1. Paul Dowsett 2011-12-29

    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
  2. Jeevan Takhar 2011-12-29

    I've updated the field with relevant information.
  3. Gruber Kristóf 2012-01-12

    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."
  4. Lee Morris 2017-05-02

    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.

JSON Source