Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1357] iOS: App Close event on IOS4 not fired

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2012-07-25T12:04:05.000+0000
Affected Version/sRelease 1.5.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
Reportergero
AssigneeNeeraj Gupta
Created2011-04-15T02:50:20.000+0000
Updated2012-07-26T22:26:32.000+0000

Description

The App's close event is not fired under iOS4.

If you press the home button, double click the home button and close the app from the "running tasks" bar (which is the way to really close an app under iOS4) no log output appears and no properties are saved with this code:

Ti.App.addEventListener('close',function() {
    Ti.API.info("Saving close event info");
    Ti.App.Properties.setInt('closeevent', 1);
});

Dont't mix up with #982 - this is a iOS4 problem. The above code works with iPhone OS 3.2.

Tested in simulator and on device.

Comments

  1. Brion Vibber 2011-04-15

    Note that the operating system does not actually inform a suspended application when it gets terminated -- there is no way to catch this condition. Apps need to perform all their cleanup when they're informed that they're being suspended; if an event isn't currently fired for that, it really needs to be.

  2. gero 2011-04-15

    Thank you for your appraisal. In this case, maybe the close event should by fired on suspension for iOS4 -- for compatibility.

    For now: there is no documented event for suspension to make a workaround for this issue -- am I missing something?

  3. Brion Vibber 2011-04-15

    Firing close on suspend is probably a bad idea, since apps are likely to assume that 'close' means their code will DEFINITELY not come back and they may do things like closing out windows and UI elements; the result would be a broken app if it's reactivated.

    I'm not aware offhand of a suspend event existing yet (I'm not a member of the development team, just another user.)

  4. Stephen Tramer 2011-04-15

    Because of how the shutdown framework works there is no guarantee this event listener will ever even be fired. Requires R&D, going to bump.

  5. Stephen Tramer 2012-07-25

    Tested with app with UIApplicationExitsOnSuspend = YES (required for iOS 4.0+). Unable to reproduce in SDK 2.2.0.f9e938d, iPhone Sim 5.1.

JSON Source