{ "id": "171788", "key": "TIMOB-26125", "fields": { "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "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": [], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-12-11T22:30:56.000+0000", "created": "2018-06-12T19:41:31.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "updated": "2018-12-11T22:30:56.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" } ], "description": "Hello,\r\nThis user wants to send the user location updates to the server every 1 minute in the background in iOS. \r\nThe app requires to keep track of the driver’s position continuously similar to Uber and send it to the server every minute. \r\n\r\n*Approach 1:* \r\nThey added location in UIBackgroundModes and tried using \r\n{code:js}\r\nTi.App.iOS.registerBackgroundService({ \r\n url : ‘locationService.js’ \r\n});\r\n{code} \r\n\r\nand have a 1-minute interval in the locationService.js \r\n\r\nIt runs fine for 3 minutes(3 times) and then it stops. \r\n\r\n*Approach 2:*\r\nThey tried using background fetch and added fetch in UIBackgroundModes along with location and used \r\n\r\n{code:js}\r\nTi.App.iOS.setMinimumBackgroundFetchInterval(Ti.App.iOS.BACKGROUNDFETCHINTERVAL_MIN);\r\n{code} \r\n\r\nIn the backgroundfetch they tried using \r\n\r\n{code:js}\r\nTi.App.iOS.addEventListener(‘backgroundfetch’, function(e) { \r\n handleLocationUpdate(); \r\n setTimeout(function() { \r\n // Put the application back to sleep \r\n Ti.App.iOS.endBackgroundHandler(e.handlerId); \r\n }, 20000); \r\n});\r\n{code}\r\n\r\nThey kept a timeout before calling {{endBackgroundHandler}} as getting the location and making the service call with the updates might take some time. \r\nThey tried without the timeout as well and still no luck. \r\n\r\nThe first problem is they cant set my desired interval of 1 min and depend on OS to execute the fetch. \r\nSecond, it gets the location and attempts to make the service call. But, the service call never goes through and they never see success/error message. But, when I bring the app to foreground immediately they see a timeout error. \r\nThird, it executes only 3 times as before and stops again. \r\n\r\n*Approach 3:* \r\nAdd an event listener for location update \r\n{code:js}\r\nTi.Geolocation.addEventListener(‘location’, updateLocation); \r\nTi.Geolocation.distanceFilter = 10; \r\n{code}\r\nthis approach again has a few problems \r\n\r\nIn spite of the distance filter, I keep getting the location update every sec or two. \r\nThey cant set the minUpdate time similar to Android to get once every minute. \r\nAlso if I try to use {{trackSignificantLocationChange}} I won't get accurate values and also will get updates only after a long significant change. \r\n\r\nThey haven’t tried this approach completely as it doesn't even meet the basic requirements. So, they don't know whether they will get location updates in the background more than thrice or will the app be able to make the service call after getting the location update.\r\n\r\nThey would like forward all the 3 approaches to our R&D team which they followed and let them know if they can send user location updates to the server every 1 minute in the background in iOS. \r\n\r\nThanks", "attachment": [], "flagged": false, "summary": "iOS: Sending background location updates to server", "creator": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "subtasks": [], "reporter": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "environment": "iOS background services", "comment": { "comments": [], "maxResults": 1, "total": 1, "startAt": 0 } } }