[TIMOB-10965] iOS: Feature: Add property to determine if the app is being launched by the OS or by the user
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-10-30T22:22:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.0.0, Release 3.1.0, 2012 Sprint 22 API, 2012 Sprint 22 |
Components | iOS |
Labels | SupportTeam, api, developer-preview, module_geolocation, qe-testadded |
Reporter | Eduardo Gomez |
Assignee | Sabil Rahim |
Created | 2012-09-18T15:59:17.000+0000 |
Updated | 2013-10-23T23:15:31.000+0000 |
Eduardo Gomez, This could be done inside the app itself by tracking the appstate through the following events [
resume
](http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.Media.Sound-event-resume), [resumed
](http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.App-event-resumed), [pause
](http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.App-event-pause) and [paused
](http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.App-event-paused). By listening to these events you could find out if the event is being fired while the user is in foreground or is starting the app or if the app is in background state and the event is being fired. Marking ticket as invalid.This is not true. I've tried this approach. If the app is force quit by the user, and then the app is launched by the OS (not the user), there is NO WAY to use the aforementioned events to determine if the app was opened by the user or the OS.
Added the expected result in order to expose the source property into resume/resumed events (as is something currently unavailable).
Allen Hartwig, If the app is forced quit by the user, then by definition the app is inactive and will not receive any more events. The only case where app is still active, is when the app is backgrounded and system still keeps the app in memory. If the app is forced quit by the user i believe iOS would not restart your app to give you updates, as the user choose not to keep the app alive anymore.
When using TrackSignificantLocationChange the OS does in fact launch the app if it's not running in the background in order to report the location change to the app. When this occurs, there is no way to programmatically determine how the app was launched, whether normally by the user or by the OS process.
Allen Hartwig Sorry i misread the Apple doc's there, but you are correct it turns out even if the app is not running in the background it wakes up the app to give the update.
Implemented a new Bool value 'location' in launchOption which could be retrieved using Ti.App.getArguments(). Testing Code
Testing Instruction. **Make an App with the above test code. **Turn trackSignificant Locations on. **Put the app into background.Wait for a bit.(to make sure the app was inactive) **Drive around and see if you receive a location notification from the app about change in location.
PR for master https://github.com/appcelerator/titanium_mobile/pull/3334