{ "id": "155296", "key": "TIMOB-20604", "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": "19957", "description": "", "name": "Release 7.1.0", "archived": false, "released": true, "releaseDate": "2018-03-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-02-28T20:38:11.000+0000", "created": "2016-03-03T00:35:50.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "geofence" ], "versions": [], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-08-06T17:49:21.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": "on iOS I am setting a location for geofencing. The code and output are below. On the iOS simulator, i set my location to the exact location of the geofence: {\"latitude\":26.2465067,\"longitude\":-98.2226709}\r\nthen to : {\"latitude\":25.2465067,\"longitude\":-98.2226709}\r\nthen back to : {\"latitude\":26.2465067,\"longitude\":-98.2226709}\r\n\r\nnone of the events are logged\r\n{code:javascript}\r\n var geoFences = e.geo_fences;\r\n var regionList = [ ];\r\n for ( var i = 0; i < geoFences.length; i++ ) {\r\n var fence = geoFences[ i ];\r\n var loc = fence.loc;\r\n var MILES_TO_METERS = 1609.34;\r\n var RAD_TO_MILES = 3959;\r\n var radius = 400; //parseFloat(loc.radius.replace(/\\/[0-9]+/, \"\")) * MILES_TO_METERS;\r\n var coordinates = {\r\n latitude: loc.coordinates[ 1 ],\r\n longitude: loc.coordinates[ 0 ]\r\n };\r\n var region = Geofence.createRegion( {\r\n center: coordinates,\r\n radius: radius,\r\n identifier: \"test\", //fence.payload.title\r\n } );\r\n Ti.API.info( 'Radius (m): ' + radius );\r\n Ti.API.info( 'Coords (m): ' + JSON.stringify(coordinates) );\r\n regionList.push( region );\r\n };\r\n // Start monitoring for region entrances/exits:\r\n Geofence.stopMonitoringAllRegions();\r\n if (regionList.length > 0) {\r\n\t Geofence.startMonitoringForRegions( regionList );\r\n }\r\n Ti.API.info( JSON.stringify( e.geo_fences ) );\r\n Ti.API.info( e.geo_fences.length );\r\n Ti.API.info(regionList.length);\r\n Ti.API.info('regions: ' + Geofence.getMonitoredRegions( ).length);\r\n\r\n // Event listener invoked when device enters a region being monitored:\r\n Geofence.addEventListener( \"error\", function( e ) {\r\n \tTI.API.info('geo error: ' + JSON.stringify(e));\r\n });\r\n Geofence.addEventListener('monitorregions', function(e) {\r\n\t // Triggered when new regions are added to be monitored\r\n\t Ti.API.info('####### monitorregion #######: ' + JSON.stringify(e));\r\n\t for (var i = 0, j = e.regions.length; i < j; i++) {\r\n\t Ti.API.info('Region id: ' + e.regions[i].identifier);\r\n\t }\r\n\t});\r\n Geofence.addEventListener( \"enterregion\", function( e ) {\r\n // Display local notification\r\n Ti.API.info('entered');\r\n } );\r\n{code}\r\nOUTPUT:\r\n\r\n[INFO] : Radius (m): 400\r\n[INFO] : Coords (m): {\"latitude\":26.2465067,\"longitude\":-98.2226709}\r\n[INFO] : [{\"id\":\"56ce0e26c6f20d3509b8c1a4\",\"loc\":{\"radius\":\".25/3959\",\"coordinates\":[-98.2226709,26.2465067]},\"payload\":{\"alert\":\"You have a new high score.\",\"icon\":\"little_star\",\"badge\":3,\"title\":\"High score alert!\",\"vibrate\":true,\"custom_field\":{\"score\":51,\"headlines\":\"And now for something completely different...\"}},\"created_at\":\"2016-02-24T20:10:14+0000\",\"updated_at\":\"2016-02-24T20:10:14+0000\"}]\r\n[INFO] : 1\r\n[INFO] : 1\r\n[INFO] : regions: 1\r\n[INFO] : ####### monitorregion #######: {\"regions\":[{}],\"bubbles\":true,\"type\":\"monitorregions\",\"source\":{\"id\":\"ti.geofence\"},\"cancelBubble\":false}\r\n[INFO] : Region id: test\r\n", "attachment": [ { "id": "63818", "filename": "ti.geofence-iphone-2.0.2.zip", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-12-15T10:00:36.000+0000", "size": 237921, "mimeType": "application/zip" } ], "flagged": false, "summary": "iOS: ti.geofence not tracking location on", "creator": { "name": "macdabby", "key": "macdabby", "displayName": "dan", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "macdabby", "key": "macdabby", "displayName": "dan", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "ti.geofence 1.1.4\r\nti.cloudpush 3.4.1\r\nti.map 2.3.6\r\nappcelerator studio 4.5.0.201602170821\r\nsdk 5.2.0GA", "closedSprints": [ { "id": 1000, "state": "closed", "name": "2018 Sprint 04 SDK", "startDate": "2018-02-12T04:23:01.913Z", "endDate": "2018-02-26T04:23:00.000Z", "completeDate": "2018-02-26T19:36:01.769Z", "originBoardId": 114 }, { "id": 126, "state": "closed", "name": "2018 Sprint 05 SDK", "startDate": "2018-02-25T19:38:08.926Z", "endDate": "2018-03-11T18:38:00.000Z", "completeDate": "2018-03-11T22:06:01.520Z", "originBoardId": 100 } ], "comment": { "comments": [ { "id": "378721", "author": { "name": "macdabby", "key": "macdabby", "displayName": "dan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "On the documentation page, http://docs.appcelerator.com/platform/latest/#!/api/Modules.Geofence, It says to use the following code: \r\nGeofence.addEventListener(\"enterregion\", function(e) { ...\r\nfurther down on the events, it says the event is called \"enterregions\" (with an \"s\" at the end)\r\n\r\nI tried using \"enterregions\" but it still did not fire an event when the region was entered.\r\n\r\nI also did not provide an error.", "updateAuthor": { "name": "macdabby", "key": "macdabby", "displayName": "dan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-03T23:43:20.000+0000", "updated": "2016-03-03T23:43:20.000+0000" }, { "id": "417037", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "This is still a issue for SDK 6.0.3.GA. Tested the module sample code on basic example. In simulator the output is:\r\ncreateRegion()\r\n\r\n{code}\r\n[INFO] REGION: [object TiGeofenceRegion] with identifier: Appcelerator\r\n{code}\r\n\r\nstartMonitoringForRegions() 1280\r\n\r\n{code}\r\n[INFO] startMonitoringForRegions() I280\r\n[INFO] ####### monitorregion #######: {\"regions\":[{}],\"bubbles\":true,\"type\":\"monitorre\r\ngions\",\"source\":{},\"cancelBubble\":false}\r\n[INFO] Region id: Test1\r\n[INFO] ####### monitorregion #######: {\"regions\":[{}],\"bubbles\":true,\"type\":\"monitorre\r\ngions\",\"source\":{},\"cancelBubble\":false}\r\n[INFO] Region id: Test2\r\n{code}\r\n\r\nstartMonitoringForRegions() appc\r\n\r\n{code}\r\n[INFO] startMonitoringForRegions() appc\r\n[INFO] ####### monitorregion #######: {\"regions\":[{}],\"bubbles\":true,\"type\":\"monitorre\r\ngions\",\"source\":{},\"cancelBubble\":false}\r\n[INFO] Region id: Appcelerator\r\n{code}\r\n\r\nTested with ti.geofence 2.0.1.Thanks.\r\n", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-04-07T16:18:39.000+0000", "updated": "2017-04-07T16:20:14.000+0000" }, { "id": "417360", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "{{monitorregions}} is fired, so \"none of them is firing\" is incorrect. And {{enterregions}} does only fire when you are not currently inside a region and you are testing with a real device. The simulator might not be able to trigger geofencing properly, since it's a different API then just Geolocation.\r\n\r\n*EDIT*: Oh, and you missspelled the event, it's called {{[enterregions|http://docs.appcelerator.com/platform/latest/#!/api/Modules.Geofence-event-enterregions]}}, not {{enterregion}}.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-04-13T15:24:01.000+0000", "updated": "2017-04-13T15:26:07.000+0000" }, { "id": "417365", "author": { "name": "dmason", "key": "dmason", "displayName": "Darren Mason", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I have been trying to implement this and I noticed that it ONLY seems to work for me if I use the *Always* key\r\nNSLocationAlwaysUsageDescription\r\nI was using the *WhenInUse* key and it wasn't firing.\r\nNSLocationWhenInUseUsageDescription\r\n\r\nAfter changing to NSLocationAlwaysUsageDescription and doing nothing else it worked.\r\n", "updateAuthor": { "name": "dmason", "key": "dmason", "displayName": "Darren Mason", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-04-13T15:52:06.000+0000", "updated": "2017-04-13T15:52:06.000+0000" }, { "id": "432151", "author": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "For this to work on iOS following pointers should be considered -\r\n\r\n1. Before start monitoring region, we have request location permission e.g. (Needs to add in doc)\r\n\r\n{code:java}\r\n Ti.Geolocation.requestLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS, function(e){\r\n Ti.API.info(e.error);\r\n if(e.success && Ti.Geolocation.hasLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS)) {\r\n Ti.API.info('Required permission granted');\r\n } else {\r\n Ti.API.info('Required permission not granted');\r\n }\r\n });\r\n{code}\r\n\r\n2. If using iOS 11 and above, we must add -\r\n NSLocationAlwaysUsageDescription, NSLocationWhenInUseUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription key in tiapp.xml. \r\n3. Below iOS 11, NSLocationAlwaysUsageDescription need to added tiapp.xml.\r\n4. For simulation, we should use device rather simulator. Simulation steps are mentioned in doc [here| http://docs.appcelerator.com/platform/latest/#!/api/Modules.Geofence].\r\n5. Sample working code (280Drive.gpx file used from sample app given in module for simulating location) - \r\n\r\n{code:java}\r\nvar win = Ti.UI.createWindow({backgroundColor: '#fff'});\r\n\r\nvar label = Ti.UI.createLabel({\r\n text: 'Click ',\r\n color: \"#333\",\r\n font: {\r\n fontSize: 20\r\n }\r\n});\r\n\r\nlabel.addEventListener('click', function(e){\r\n var Geofence = require('ti.geofence');\r\n var newRegion1 = Geofence.createRegion({\r\n center: {\r\n latitude:37.389601,\r\n longitude:-122.050169\r\n },\r\n radius:1000,\r\n identifier:'Appcelerator'\r\n });\r\n\r\n var newRegion2 = Geofence.createRegion({\r\n center: {\r\n latitude:37.353732000,\r\n longitude:-122.108480000\r\n },\r\n radius:1000,\r\n identifier:'Axway'\r\n });\r\n\r\n Ti.Geolocation.requestLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS, function(e){\r\n Ti.API.info(e.error);\r\n if(e.success && Ti.Geolocation.hasLocationPermissions(Titanium.Geolocation.AUTHORIZATION_ALWAYS)) {\r\n Ti.API.info('Required permission granted');\r\n } else {\r\n Ti.API.info('Required permission not granted');\r\n }\r\n });\r\n \r\n Geofence.startMonitoringForRegions([newRegion1, newRegion2]);\r\n\r\n Geofence.addEventListener(\"enterregions\", function(e) {\r\n Ti.API.info('####### enterregions #######: ' + JSON.stringify(e));\r\n for (var i = 0, j = e.regions.length; i < j; i++) {\r\n Ti.API.info('Region id: ' + e.regions[i].identifier);\r\n }\r\n });\r\n\r\n Geofence.addEventListener('monitorregions', function(e) {\r\n Ti.API.info('####### monitorregion #######: ' + JSON.stringify(e));\r\n for (var i = 0, j = e.regions.length; i < j; i++) {\r\n Ti.API.info('Region id: ' + e.regions[i].identifier);\r\n }\r\n });\r\n\r\n Geofence.addEventListener('exitregions', function(e) {\r\n Ti.API.info('####### exitregions #######: ' + JSON.stringify(e));\r\n for (var i = 0, j = e.regions.length; i < j; i++) {\r\n Ti.API.info('Region id: ' + e.regions[i].identifier);\r\n }\r\n });\r\n});\r\nwin.add(label);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "vijaysingh", "key": "vijaysingh", "displayName": "Vijay Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-12-14T09:08:22.000+0000", "updated": "2017-12-14T09:09:08.000+0000" }, { "id": "432204", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator-modules/ti.geofence/pull/41\r\n\r\nThis PR updates Ti.Geofence to use the latest API's and replaces all deprecated API's. It also adds the \"requestStateForRegion\" method and \"regionstate\" event to receive cached region events.\r\n\r\nA prerelease-version is attached to this ticket!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-12-15T10:00:17.000+0000", "updated": "2017-12-15T10:00:17.000+0000" }, { "id": "435025", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "FR Passed. Location is correctly tracked and I receive enter and exit location events while monitoring regions. Tested using the provided samples as well as the geolocation/geofence suite", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2018-02-28T20:38:11.000+0000", "updated": "2018-02-28T20:38:11.000+0000" }, { "id": "440129", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T17:49:21.000+0000", "updated": "2018-08-06T17:49:21.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }