{ "id": "78564", "key": "TIMOB-4875", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "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": "12077", "description": "", "name": "Sprint 2011-37", "archived": true, "released": true, "releaseDate": "2011-09-19" } ], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2011-09-14T13:04:52.000+0000", "created": "2011-08-01T05:26:40.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-23T21:38:10.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": "When running your app in the foreground, if you press the home button then background services work as expected, however if you \"Lock\" the device (CMD+L in the simulator, top button on the device) then the background code never runs.\r\n\r\nHere's how to reproduce it in two simple files that can be dropped into a new project.\r\n\r\napp.js:\r\n{code}\r\nvar w = Ti.UI.createWindow(); \r\nvar bgsvc = Ti.App.iOS.registerBackgroundService({ url: '/bg.js' }); \r\nTi.App.addEventListener('pause', function(e) { \r\n Ti.API.debug(\"pause fired\"); \r\n}); \r\n\r\nTi.App.addEventListener('resumed', function(e) { \r\n Ti.API.debug(\"resumed fired\"); \r\n}); \r\n\r\nw.open(); \r\n{code}\r\n\r\nbg.js: \r\n{code}\r\nTi.API.debug(\"Hi from bg.js, about to loop forever\"); \r\nfunction bgfunc() { \r\n setTimeout(bgfunc, 5000); \r\n Ti.API.debug(\"Hi from bgfunc\"); \r\n}\r\nbgfunc();\r\n{code}\r\n\r\nRunning the above code I see the following when pressing the home button:\r\n{noformat}\r\n[INFO] bgtest/1.0 (1.7.1.1293a6d) \r\n[DEBUG] Analytics is enabled = YES \r\n[DEBUG] loading: /Users/evan/Projects/Titanium/bgtest/Resources/ \r\napp.js, resource: Users/evan/Projects/Titanium/bgtest/Resources/app_js \r\n[DEBUG] application booted in 28.014004 ms \r\n[DEBUG] fire app event: pause \r\n[DEBUG] pause fired \r\n[DEBUG] loading: /Users/evan/Projects/Titanium/bgtest/Resources/bg.js, \r\nresource: Users/evan/Projects/Titanium/bgtest/Resources/bg_js \r\n[DEBUG] Hi from bg.js, about to loop forever \r\n[DEBUG] Hi from bgfunc \r\n[DEBUG] Hi from bgfunc \r\n... continues every 5 seconds ... \r\n[DEBUG] fire app event: resumed \r\n[DEBUG] resumed fired \r\n{noformat}\r\n\r\nBut if I run the app and push the lock button I get:\r\n{noformat}\r\n[INFO] bgtest/1.0 (1.7.1.1293a6d) \r\n[DEBUG] Analytics is enabled = YES \r\n[DEBUG] loading: /Users/evan/Projects/Titanium/bgtest/Resources/ \r\napp.js, resource: Users/evan/Projects/Titanium/bgtest/Resources/app_js \r\n[DEBUG] application booted in 27.069032 ms \r\n[DEBUG] fire app event: pause \r\n[DEBUG] pause fired \r\n... wait 10 seconds, unlock ... \r\n[DEBUG] fire app event: resumed \r\n[DEBUG] resumed fired \r\n{noformat}\r\n\r\nI have found a similar question on the developers site: http://developer.appcelerator.com/question/116667/ios-background-geolocation-in-16\r\n\r\nIn the second comment there is a link to a github URL that contains a fork of titanium: https://github.com/mpociot/titanium_mobile/commit/4853f091639e899545f9d1ef1416b1ca5baa0746\r\n\r\nThe code in the fork seems to address the issue and enables background services to run on lock. Can this be merged into Titanium?", "attachment": [], "flagged": false, "summary": "iOS: Background services do not run when the app is locked", "creator": { "name": "evan", "key": "evan", "displayName": "Evan Borgstrom", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "evan", "key": "evan", "displayName": "Evan Borgstrom", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Ti SDK: 1.7.1.1293a6d & 1.7.2.97c3689\r\niOS SDK: 4.2 & 4.3\r\nBuild Platform: OSX 10.6.8", "comment": { "comments": [ { "id": "161601", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Evan\r\n\r\nIt's so nice to see a well-thought-out ticket like this one. Thank you for raising it.\r\n\r\nI note that your logs show that you tested your code on 1.7.1.1293a6d but in the environment field you have entered Titanium SDK 1.7.2. Would you mind entering all the versions you have tried into the environment field, in the format that includes the build hash (like 1.7.1.1293a6d does).\r\n\r\nThen I can move this ticket to the correct project.\r\n\r\nCheers", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-08-02T16:45:43.000+0000", "updated": "2011-08-02T16:45:43.000+0000" }, { "id": "161651", "author": { "name": "evan", "key": "evan", "displayName": "Evan Borgstrom", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Paul,\r\n\r\nMy pleasure. Happy to contribute back. I've been playing with Titanium for about 18 months now, but have just undertaken my first real project with it.\r\n\r\nI've updated the environment field to include the exact build versions of the two SDK's I've tested against.", "updateAuthor": { "name": "evan", "key": "evan", "displayName": "Evan Borgstrom", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-03T04:36:06.000+0000", "updated": "2011-08-03T04:36:06.000+0000" }, { "id": "164595", "author": { "name": "matthewcongrove", "key": "matthewcongrove", "displayName": "Matthew Congrove", "active": true, "timeZone": "America/Chicago" }, "body": "Bumped priority.", "updateAuthor": { "name": "matthewcongrove", "key": "matthewcongrove", "displayName": "Matthew Congrove", "active": true, "timeZone": "America/Chicago" }, "created": "2011-08-31T08:06:02.000+0000", "updated": "2011-08-31T08:06:02.000+0000" }, { "id": "164596", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "There seems to be a fix to this issue:\r\n\r\nhttps://github.com/mpociot/titanium_mobile/commit/4853f091639e899545f9d1ef1416b1ca5baa0746", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-08-31T08:45:25.000+0000", "updated": "2011-08-31T08:45:25.000+0000" }, { "id": "166053", "author": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is actually working properly as designed. When the device is locked, the application is not changed to the background state and foreground processes still run. We therefore properly do no fire off the background tasks.", "updateAuthor": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-09-14T13:04:28.000+0000", "updated": "2011-09-14T13:04:28.000+0000" }, { "id": "415418", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid with reference to the previous comments.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-23T21:38:10.000+0000", "updated": "2017-03-23T21:38:10.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }