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.
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!
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.
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 thepaused
event for app's launched in the background (e.g. for background-services or remote push notifications).Tested on latest master and it works already, see the linked fix above.
Closing as a duplicate. If this is in error, please reopen.