Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18179] iOS: Missing app-state-events for fresh launch and background-launch

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2017-10-25T21:59:16.000+0000
Affected Version/sRelease 3.2.3, Release 3.3.0, Release 3.4.0, Release 3.4.1
Fix Version/sn/a
ComponentsiOS
LabelsTCSupportTriage, ios, mobile, reprod, titanium
ReporterShawn Lan
AssigneeHans Knöchel
Created2014-06-27T18:26:06.000+0000
Updated2018-08-06T17:41:08.000+0000

Description

Problem Description

1. Titanium mobile app doesn't fire "resumed" event at fresh launch. Based on Apple's doc, "applicationDidBecomeActive:" is called at fresh launch as well. Shouldn't "resumed" be fired at fresh launch? 2. Based on #1, Shouldn't Titanium mobile app fire "paused" event when app is launched directly into the background? Since "applicationDidEnterBackground:" is called in this case. 3. There is currently no way to determine whether app is launched into the foreground or the background with Titanium. It is possible with native code, according to Apple's Docs. This feature is highly needed.

Test case

1. Create a new mobile project (Classic Titanium) 2. Copy this code into app.js
var main_window = Ti.UI.createWindow({
	backgroundColor: 'green'
});
main_window.open();

Titanium.App.addEventListener('pause', function (e) {
    Ti.API.info('app.js: Pause event on '+Ti.Platform.osname);
}); 
Titanium.App.addEventListener('paused', function (e) {
    Ti.API.info('app.js: Paused event on '+Ti.Platform.osname);
});     
Titanium.App.addEventListener('resume', function (e) {
    Ti.API.info('app.js: Resume event on '+Ti.Platform.osname);
});
Titanium.App.addEventListener('resumed', function (e) {
    Ti.API.info('app.js: Resumed event on '+Ti.Platform.osname);
});
3. Run it into device

Extra info

According to the "Apple Doc" The "resumed" event should also called at app fresh launch. According to Apple Doc ["applicationDidBecomeActive"](https://developer.apple.com/library/ios/documentation/uikit/reference/uiapplicationdelegate_protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/applicationDidBecomeActive:) is called at fresh launch, which invoke the Titanium.App "resumed" event.

Comments

  1. Mauro Parra-Miranda 2014-07-18

    Hello [~shawnlan]! Can you please read this: http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.App-event-resume and let us know if that covers 1 and 2, or if you need something else? Please check resume and resumed. Best Regards!
  2. Shawn Lan 2014-07-18

    No it doesn't cover 1 and 2. I know how "resume" and "resumed" events work in Titanium. My problem is that "resumed" (and probably "paused" too) event doesn't work as intended. That is, at "fresh launch" (not resumed from the background), the "resumed" event is not fired. According to Apple's doc, "applicationDidBecomeActive:" is called at "fresh launch" as well. Titanium's "resumed" event should go together with "applicationDidBecomeActive," right? I don't understand why it's not, and am curious about how its implementation looks like.
  3. Hans Knöchel 2017-06-30

    This issue is valid and will be addressed, as soon as TIMOB-20272 is merged. The reason it happens is because the notification is sent before Ti.App namespace is registering for the event, so the notification gets lost in translation. Having TIMOB-20272 merged, we are able to send the event as soon as the app is ready. Same thing for the paused event for app's launched in the background (e.g. for background-services or remote push notifications).
  4. Hans Knöchel 2017-10-25

    Tested on latest master and it works already, see the linked fix above.
  5. Eric Merriman 2018-08-06

    Closing as a duplicate. If this is in error, please reopen.

JSON Source