{ "id": "171293", "key": "TIMOB-25858", "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": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2018-07-26T21:54:08.000+0000", "created": "2018-03-12T18:50:26.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [ "geolocation", "ios" ], "versions": [], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-07-26T21:54:08.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "Hello, \r\n\r\nOn iOS, when using Ti.Geolocation.trackSignificantLocationChange and dealing with background updates with args.launchOptionsLocationKey we are seeing an issue where after a background update has come in while the app was closed and the next launch of the app hangs on the splash screen. The app must be manually closed in order to get farther than the splash screen. \r\n\r\n*Example Code:*\r\nExample app attached. \r\n\r\n*To reproduce:* \r\n1. Install app on physical device and choose \"Always\" allow location permission. \r\n2. Force close app with the test switcher \r\n3. Move device until you get a background location update \r\n4. Launch the app and observe the app hang on the launch screen", "attachment": [ { "id": "64956", "filename": "test-background-location.zip", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2018-03-12T18:46:37.000+0000", "size": 5546906, "mimeType": "application/zip" } ], "flagged": false, "summary": "iOS: Question on how to use \"trackSignificantLocationChange\" with background location update", "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": "Ti.Geolocation, trackSignificantLocationChange, background updates", "closedSprints": [ { "id": 1053, "state": "closed", "name": "2018 Sprint 15 SDK", "startDate": "2018-07-15T21:52:05.453Z", "endDate": "2018-07-29T21:52:00.000Z", "completeDate": "2018-07-29T22:25:11.723Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "435543", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I highly suspect that the app crashes because the launch-keys contain a key that is not bridged so far. This would be indicated by having this issue on specific iOS-versions. I will update the ticket with my findings.\r\n\r\n*EDIT*: I am having a hard time trying to trigger the significant location without going on a train ride now. I'll try some more, but hints on how that was tested on your side would be appreciated!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-13T16:01:27.000+0000", "updated": "2018-03-13T16:43:29.000+0000" }, { "id": "435544", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Okay, here is the issue: You are checking for the location-based launch in the following snippet:\r\n{code:js}\r\nif (isiOS()) {\r\n var args = Ti.App.getArguments();\r\n if (args.launchOptionsLocationKey) {\r\n Ti.API.info (\"[APP] launched on location update\");\r\n Ti.App.Properties.setBool('loc_updated', true);\r\n }\r\n else {\r\n start_app();\r\n }\r\n}\r\nelse {\r\n start_app();\r\n}\r\n{code}\r\nIf the app is Android, you skip the location-handling and just launch it. But for iOS, if the app is opened by the location update (2nd nested if-statement), you only set the Ti.App.Properties flag but don't actually finish launching. Now when opening the app (in a time where the app was not auto-killed by iOS due to background inactivity), the launch was already booted, but the window wasn't opened, resulting in exactly this behavior (the displayed splash screen).\r\n\r\nI would propose that you simply do the same app-setup (opening the app / root window) and it will be fixed. In addition, I would recommend to clean up the \"location\" event-listener when closing the app, as it may be added twice if not (although not tested so far). Here is my (working) test-case (that also simplifies the if-statements):\r\n{code:js}\r\nfunction start_app() {\r\n var launched = Ti.App.Properties.getBool('loc_updated', false);\r\n\r\n if (launched) {\r\n Ti.API.warn(\"app launched in background\");\r\n }\r\n\r\n var win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n });\r\n\r\n win.addEventListener('open', function() {\r\n if (Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS)) {\r\n Titanium.Geolocation.addEventListener('location', locationCallback);\r\n } else {\r\n requestLocationPermissions();\r\n }\r\n });\r\n win.addEventListener('close', function() {\r\n if (!Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS)) {\r\n return;\r\n }\r\n Titanium.Geolocation.removeEventListener('location', locationCallback);\r\n });\r\n win.add(Ti.UI.createLabel({\r\n text: 'Hello World!'\r\n }));\r\n win.open();\r\n}\r\n\r\nfunction isiOS() {\r\n return Ti.Platform.name === 'iOS' || Ti.Platform.name === 'iPhone OS';\r\n}\r\n\r\nfunction requestLocationPermissions() {\r\n Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {\r\n Ti.Geolocation.trackSignificantLocationChange = true;\r\n Titanium.Geolocation.addEventListener('location', locationCallback);\r\n });\r\n}\r\n\r\nfunction locationCallback(e) {\r\n Ti.API.info(\"[app] got location update\");\r\n}\r\n\r\nif (isiOS()) {\r\n var args = Ti.App.getArguments();\r\n if (args.launchOptionsLocationKey) {\r\n Ti.API.info(\"[APP] launched on location update\");\r\n Ti.App.Properties.setBool('loc_updated', true);\r\n }\r\n}\r\n\r\nstart_app();\r\n{code}\r\n\r\nLet me know if this is working for you!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-13T17:32:16.000+0000", "updated": "2018-03-13T17:32:16.000+0000" }, { "id": "435573", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I've updated the JIRA ticket to reflect this to be a {{Story}} instead of a {{Bug}} as it's the same behavior as natively.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-03-14T09:30:53.000+0000", "updated": "2018-03-14T09:30:53.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }