{ "id": "101444", "key": "TIMOB-10965", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" }, { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" }, { "id": "14168", "description": "2012 Sprint 22 API", "name": "2012 Sprint 22 API", "archived": true, "released": true, "releaseDate": "2012-11-05" }, { "id": "14274", "description": "2012 Sprint 22", "name": "2012 Sprint 22", "archived": true, "released": true, "releaseDate": "2012-11-05" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-10-30T22:22:41.000+0000", "created": "2012-09-18T15:59:17.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "SupportTeam", "api", "developer-preview", "module_geolocation", "qe-testadded" ], "versions": [], "issuelinks": [ { "id": "21641", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "97654", "key": "TIMOB-10041", "fields": { "summary": "iOS: Feature: Expose startMonitoringSignificantLocationChanges method", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-10-23T23:15:31.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "attachment": [], "flagged": false, "summary": "iOS: Feature: Add property to determine if the app is being launched by the OS or by the user", "creator": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK 2.1.3.GA", "comment": { "comments": [ { "id": "222555", "author": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Eduardo Gomez,\n\nThis 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].\n\nBy 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. \n\n\nMarking ticket as invalid.\n", "updateAuthor": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-08T18:16:20.000+0000", "updated": "2012-10-08T18:16:20.000+0000" }, { "id": "222558", "author": { "name": "allenhartwig", "key": "allenhartwig", "displayName": "Allen Hartwig", "active": true, "timeZone": "America/Los_Angeles" }, "body": "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.", "updateAuthor": { "name": "allenhartwig", "key": "allenhartwig", "displayName": "Allen Hartwig", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-08T18:22:27.000+0000", "updated": "2012-10-08T18:22:27.000+0000" }, { "id": "222565", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Added the expected result in order to expose the source property into resume/resumed events (as is something currently unavailable).\r\n", "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-10-08T19:10:42.000+0000", "updated": "2012-10-08T19:10:42.000+0000" }, { "id": "222570", "author": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Allen Hartwig,\n\n 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.", "updateAuthor": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-08T19:50:19.000+0000", "updated": "2012-10-08T19:50:19.000+0000" }, { "id": "222571", "author": { "name": "allenhartwig", "key": "allenhartwig", "displayName": "Allen Hartwig", "active": true, "timeZone": "America/Los_Angeles" }, "body": "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.", "updateAuthor": { "name": "allenhartwig", "key": "allenhartwig", "displayName": "Allen Hartwig", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-08T19:57:15.000+0000", "updated": "2012-10-08T19:57:15.000+0000" }, { "id": "222572", "author": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Allen Hartwig\n 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. ", "updateAuthor": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-08T20:08:58.000+0000", "updated": "2012-10-08T20:08:58.000+0000" }, { "id": "225129", "author": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Implemented a new Bool value 'location' in launchOption which could be retrieved using Ti.App.getArguments().\r\n\r\nTesting Code \r\n\r\n{code}\r\nvar locationUpdated = false;\r\nvar args = Ti.App.getArguments();\r\nif(args.launchOptionsLocationKey == true)\r\n{\r\n    var notification = Ti.App.iOS.scheduleLocalNotification({\r\n        alertBody:\"Location Update from background received \\n\",\r\n        alertAction:\"Re-Launch!\",\r\n        date:new Date(new Date().getTime() ) \r\n    });\r\n    locationUpdated = true; \r\n}\r\nTi.API.info('Ti.App.getArguments() ::'+args);\r\n \r\nTi.App.addEventListener('resumed',function(){\r\n     \r\n    Ti.API.info(\"app has resumed from the background\");\r\n    if(args.launchOptionsLocationKey == true)\r\n    {\r\n        var notification = Ti.App.iOS.scheduleLocalNotification({\r\n            alertBody:\"Location Update from background received \\n\",\r\n            alertAction:\"Re-Launch!\",\r\n            date:new Date(new Date().getTime() ) \r\n        });\r\n        locationUpdated = true; \r\n    }\r\n    Ti.API.info('Ti.App.getArguments() ::'+Ti.App.getArguments());\r\n});\r\n  \r\nTitanium.App.addEventListener('pause',function(e)\r\n{\r\n    alert(JSON.stringify(e));\r\n    Ti.API.info(\"PAUSED\");      \r\n});\r\n   \r\n//setting up the GPS necessary stuff\r\n \r\nTi.Geolocation.preferredProvider = \"gps\";\r\n       \r\nTi.Geolocation.purpose = \"GPS demo for `startmonitoringlocationupdates`\";\r\n       \r\nfunction translateErrorCode(code) {\r\n    if (code == null) {\r\n        return null;\r\n    }\r\n    switch (code) {\r\n        case Ti.Geolocation.ERROR_LOCATION_UNKNOWN:\r\n            return \"Location unknown\";\r\n        case Ti.Geolocation.ERROR_DENIED:\r\n            return \"Access denied\";\r\n        case Ti.Geolocation.ERROR_NETWORK:\r\n            return \"Network error\";\r\n        case Ti.Geolocation.ERROR_HEADING_FAILURE:\r\n            return \"Failure to detect heading\";\r\n        case Ti.Geolocation.ERROR_REGION_MONITORING_DENIED:\r\n            return \"Region monitoring access denied\";\r\n        case Ti.Geolocation.ERROR_REGION_MONITORING_FAILURE:\r\n            return \"Region monitoring access failure\";\r\n        case Ti.Geolocation.ERROR_REGION_MONITORING_DELAYED:\r\n            return \"Region monitoring setup delayed\";\r\n    }\r\n}   \r\n \r\n//  SHOW CUSTOM ALERT IF DEVICE HAS GEO TURNED OFF\r\n//\r\nif (Titanium.Geolocation.locationServicesEnabled === false)\r\n{\r\n    Titanium.UI.createAlertDialog({title:'Kitchen Sink', message:'Your device has geo turned off - turn it on.'}).show();\r\n}\r\nelse\r\n{\r\n    var authorization = Titanium.Geolocation.locationServicesAuthorization;\r\n    Ti.API.info('Authorization: '+authorization);\r\n    if (authorization == Titanium.Geolocation.AUTHORIZATION_DENIED) {\r\n        Ti.UI.createAlertDialog({\r\n            title:Titanium.App.getName(),\r\n            message:'You have disallowed Titanium from running geolocation services.'\r\n        }).show();\r\n    }\r\n    else if (authorization == Titanium.Geolocation.AUTHORIZATION_RESTRICTED) {\r\n        Ti.UI.createAlertDialog({\r\n            title:Titanium.App.getName(),\r\n            message:'Your system has disallowed Titanium from running geolocation services.'\r\n        }).show();\r\n    }\r\n   \r\n   \r\n         \r\n     \r\n   \r\n    //\r\n    //  SET ACCURACY - THE FOLLOWING VALUES ARE SUPPORTED\r\n    //\r\n    // Titanium.Geolocation.ACCURACY_BEST\r\n    // Titanium.Geolocation.ACCURACY_NEAREST_TEN_METERS\r\n    // Titanium.Geolocation.ACCURACY_HUNDRED_METERS\r\n    // Titanium.Geolocation.ACCURACY_KILOMETER\r\n    // Titanium.Geolocation.ACCURACY_THREE_KILOMETERS\r\n    //\r\n    Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;\r\n   \r\n    //\r\n    //  SET DISTANCE FILTER.  THIS DICTATES HOW OFTEN AN EVENT FIRES BASED ON THE DISTANCE THE DEVICE MOVES\r\n    //  THIS VALUE IS IN METERS\r\n    //\r\n    Titanium.Geolocation.distanceFilter = 10;\r\n   \r\n    //The app was turned on while in background.Should only set up the LocationManager to track Significant changes only.\r\n    if(locationUpdated == true){\r\n    \tTitanium.Geolocation.trackSignificantLocationChange = true;\r\n    }\r\n     \r\n    //\r\n    // EVENT LISTENER FOR GEO EVENTS - THIS WILL FIRE REPEATEDLY (BASED ON DISTANCE FILTER)\r\n    //\r\n    var locationCallback = function(e)\r\n    {\r\n        if (!e.success || e.error)\r\n        {\r\n            updatedLocation.text = 'error:' + JSON.stringify(e.error);\r\n            updatedLatitude.text = '';\r\n            updatedLocationAccuracy.text = '';\r\n            updatedLocationTime.text = '';\r\n            Ti.API.info(\"Code translation: \"+translateErrorCode(e.code));\r\n            return;\r\n        }\r\n   \r\n        var longitude = e.coords.longitude;\r\n        var latitude = e.coords.latitude;\r\n        var altitude = e.coords.altitude;\r\n        var heading = e.coords.heading;\r\n        var accuracy = e.coords.accuracy;\r\n        var speed = e.coords.speed;\r\n        var timestamp = e.coords.timestamp;\r\n        var altitudeAccuracy = e.coords.altitudeAccuracy;\r\n   \r\n        //Titanium.Geolocation.distanceFilter = 100; //changed after first location event\r\n          if(locationUpdated == false){\r\n     \r\n            updatedLocation.text = 'long:' + longitude;\r\n            updatedLatitude.text = 'lat: '+ latitude;\r\n            updatedLocationAccuracy.text = 'accuracy:' + accuracy;\r\n            updatedLocationTime.text = 'timestamp:' +new Date(timestamp);\r\n       \r\n            updatedLatitude.color = 'red';\r\n            updatedLocation.color = 'red';\r\n            updatedLocationAccuracy.color = 'red';\r\n            updatedLocationTime.color = 'red';\r\n            setTimeout(function()\r\n            {\r\n                updatedLatitude.color = '#444';\r\n                updatedLocation.color = '#444';\r\n                updatedLocationAccuracy.color = '#444';\r\n                updatedLocationTime.color = '#444';\r\n       \r\n            },100);\r\n       \r\n        }\r\n        else\r\n        {\r\n                var notification = Ti.App.iOS.scheduleLocalNotification({\r\n                    alertBody:\"Location Update Received.\",\r\n                    alertAction:\"Re-Launch!\",\r\n                    userInfo:{\"hello\":\"world\"},\r\n                    sound:\"pop.caf\",\r\n                    date:new Date(new Date().getTime() + 3000) // 3 seconds after backgrounding\r\n                });\r\n        }        \r\n   \r\n        Titanium.API.info('geo - location updated: ' + new Date(timestamp) + ' long ' + longitude + ' lat ' + latitude + ' accuracy ' + accuracy);\r\n    };\r\n    Titanium.Geolocation.addEventListener('location', locationCallback);\r\n    locationAdded = true;\r\n}\r\n \r\n \r\n \r\n//Create the UI only if the app opened as a consequence of User interaction with the app.\r\n \r\nif(locationUpdated == false)\r\n{\r\n    var win = Titanium.UI.createWindow({\r\n        backgroundColor:'white'\r\n    });\r\n \r\n    var updatedLocationLabel = Titanium.UI.createLabel({\r\n        text:'Updated Location',\r\n        font:{fontSize:12, fontWeight:'bold'},\r\n        color:'#111',\r\n        top:150,\r\n        left:10,\r\n        height:15,\r\n        width:300\r\n    });\r\n    win.add(updatedLocationLabel);\r\n       \r\n    var updatedLocation = Titanium.UI.createLabel({\r\n        text:'Updated Location not fired',\r\n        font:{fontSize:11},\r\n        color:'#444',\r\n        top:170,\r\n        left:10,\r\n        height:15,\r\n        width:300\r\n    });\r\n    win.add(updatedLocation);\r\n       \r\n    var updatedLatitude = Titanium.UI.createLabel({\r\n        text:'',\r\n        font:{fontSize:11},\r\n        color:'#444',\r\n        top:190,\r\n        left:10,\r\n        height:15,\r\n        width:300\r\n    });\r\n    win.add(updatedLatitude);\r\n       \r\n    var updatedLocationAccuracy = Titanium.UI.createLabel({\r\n        text:'',\r\n        font:{fontSize:11},\r\n        color:'#444',\r\n        top:210,\r\n        left:10,\r\n        height:15,\r\n        width:300\r\n    });\r\n    win.add(updatedLocationAccuracy);\r\n       \r\n    var updatedLocationTime = Titanium.UI.createLabel({\r\n        text:'',\r\n        font:{fontSize:11},\r\n        color:'#444',\r\n        top:230,\r\n        left:10,\r\n        height:15,\r\n        width:300\r\n    });\r\n    win.add(updatedLocationTime);\r\n       \r\n     \r\n       \r\n    var button = Ti.UI.createButton({\r\n        title:'Track Significant Location Change(TSLC)',\r\n        width:Ti.UI.SIZE,\r\n        height:Ti.UI.SIZE,\r\n        backgroundColor: '',\r\n        bottom:70\r\n    });\r\n    button.addEventListener('click',function(){\r\n        var val = Ti.Geolocation.trackSignificantLocationChange;\r\n        Ti.Geolocation.trackSignificantLocationChange = !val;\r\n    });\r\n    win.add(button);\r\n    //Check track significant value\r\n    var button2 = Ti.UI.createButton({\r\n        title:'Check value of TSLC',\r\n        width:Ti.UI.SIZE,\r\n        height:Ti.UI.SIZE,\r\n        backgroundColor: 'grey',\r\n        bottom:5\r\n    });\r\n    button2.addEventListener('click',function(){\r\n        var value = Ti.Geolocation.trackSignificantLocationChange;\r\n        Ti.API.info('---> Ti.Geolocation.trackingSignificantLocationChange ?'+ value);\r\n        Titanium.UI.createAlertDialog({title:'GPS',message:'trackingSignificantLocationChange:'+value}).show();\r\n       \r\n    });\r\n    win.add(button2);\r\n       \r\n    // state vars used by resume/pause\r\n    //var headingAdded = false;\r\n    var locationAdded = false;\r\n       \r\n     \r\n    var addr = \"2065 Hamilton Avenue San Jose California 95125\";\r\n    win.open();\r\n}\r\nelse{\r\n     Titanium.Geolocation.addEventListener('location', locationCallback);\r\n     locationAdded = true;\r\n}\r\n{code}", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-10-26T18:12:32.000+0000", "updated": "2012-10-30T22:21:53.000+0000" }, { "id": "225132", "author": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Testing Instruction.\r\n\r\n**Make an App with the above test code. \r\n**Turn trackSignificant Locations on.\r\n**Put the app into background.Wait for a bit.(to make sure the app was inactive)\r\n**Drive around and see if you receive a location notification from the app about change in location.\r\n\r\n", "updateAuthor": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-26T18:18:44.000+0000", "updated": "2012-10-26T18:21:09.000+0000" }, { "id": "225135", "author": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR for master https://github.com/appcelerator/titanium_mobile/pull/3334", "updateAuthor": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-26T18:22:57.000+0000", "updated": "2012-10-26T18:22:57.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }