{ "id": "92529", "key": "AC-2869", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-03-08T22:42:00.000+0000", "created": "2012-05-30T04:45:46.000+0000", "labels": [ "eventlistener", "geolocation" ], "versions": [], "issuelinks": [], "assignee": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:47:49.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "If Ti.Geolocation.removeEventListener() is called when Ti.Geolocation.addEventListener() has NOT been added the system remembers and subsequently removes the listener once you add it, even if this is at a later time.\r\n\r\nIn the following example use these click orders:\r\n\r\nThis works Correctly:\r\n - Add Event Listener\r\n - Remove Event Listener\r\n - Add Event listener\r\n\r\nThis does not work correctly\r\n - Remove Event Listener\r\n - Add Event Listener\r\n\r\nhowever clicking Add event Listener again will work.\r\n\r\nThis also stacks. Clicking Remove Event Listener 5 times, means that Add Event Listener needs to be clicked 5 times before it starts delivering events.\r\n\r\nThe example shows calls for 'heading' but I believe this also occurs for location.\r\n\r\n{code}\r\n\r\nTi.Geolocation.preferredProvider \t\t\t\t= \tTi.Geolocation.PROVIDER_GPS;\r\nTi.Geolocation.accuracy \t\t\t\t\t= \tTitanium.Geolocation.ACCURACY_HIGH;\r\nTi.Geolocation.purpose \t\t\t\t\t\t= \t'Determine Position';\r\nTi.Geolocation.headingFilter \t\t\t\t\t= \t5;\r\nTi.Geolocation.showCalibration \t\t\t\t\t= \ttrue;\r\nTi.Geolocation.distanceFilter\t\t\t\t\t=\t10;\r\n\r\n\t\r\nvar win1 = Titanium.UI.createWindow({ \r\n backgroundColor:'#fff'\r\n});\r\n\r\nvar btnAdd = Ti.UI.createButton({\r\n\ttop: 100,\r\n\ttitle: 'Add Event Listener',\r\n})\r\n\r\nbtnAdd.addEventListener('click', addGeoEvent);\r\n\r\nvar btnRemove = Ti.UI.createButton({\r\n\ttop:\t200,\r\n\ttitle: 'Remove Event Listener',\r\n})\r\n\r\nbtnRemove.addEventListener('click', removeGeoEvent);\r\n\r\nwin1.add(btnAdd);\r\nwin1.add(btnRemove);\r\n\r\nfunction addGeoEvent(){\r\n\tTi.API.info('adding listener');\r\n\tTi.Geolocation.addEventListener('heading', headingCallback);\r\n}\r\n\r\nfunction removeGeoEvent(){\r\n\tTi.API.info('removing listener');\r\n\tTi.Geolocation.removeEventListener('heading', headingCallback);\r\n}\r\n\r\nfunction headingCallback(e){\r\n\t\r\n\tTi.API.info('heading = ' + e.heading.magneticHeading);\r\n\t\r\n}\r\n\r\nwin1.open();\r\n\r\n\r\n\r\n{code}\r\n\r\n\r\n", "attachment": [], "flagged": false, "summary": "Calling removeEventListener on Geolocation event prevents addEventListener from working", "creator": { "name": "martz256", "key": "martz256", "displayName": "Martyn Joyce", "active": true, "timeZone": "Europe/London" }, "subtasks": [], "reporter": { "name": "martz256", "key": "martz256", "displayName": "Martyn Joyce", "active": true, "timeZone": "Europe/London" }, "environment": "Titanium Mobile iOS SDK: v2.0.1GA2", "comment": { "comments": [ { "id": "197737", "author": { "name": "nsharma", "key": "nsharma", "displayName": "Nikhil Sharma", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Martyn,\r\nWhat platform you're referring to Android or iOS? I tested the above test case on iPhone and its working fine.", "updateAuthor": { "name": "nsharma", "key": "nsharma", "displayName": "Nikhil Sharma", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-06-07T12:03:03.000+0000", "updated": "2012-06-07T12:03:03.000+0000" }, { "id": "198131", "author": { "name": "martz256", "key": "martz256", "displayName": "Martyn Joyce", "active": true, "timeZone": "Europe/London" }, "body": "Hi Nikhil, this is on iOS version 5.1\r\n\r\nhowever, apologies, my use-case above seems to be slightly off:\r\n\r\nThis DOES work in the first instance\r\n\r\n1 - Remove Event Listener\r\n2 - Add Event Listener\r\n\r\nBut if you continue it stops working i.e.\r\n\r\n1 - Remove Event Listener\r\n2 - Add Event Listener\r\n3 - Remove Event Listener\r\n4 - Remove Event Listener\r\n5 - Remove Event Listener\r\n6 - Add Event Listener - no events are generated here\r\n7 - Add Event Listener - no events are generated here\r\n8 - Add Event Listener - events are now generated\r\n\r\nIn practice this occurs because we 'remove' as a safety measure to make sure the gps is turned off, however using variables to keep track of the status has solved my problem temporarily. \r\n\r\nthanks\r\n\r\n\r\n", "updateAuthor": { "name": "martz256", "key": "martz256", "displayName": "Martyn Joyce", "active": true, "timeZone": "Europe/London" }, "created": "2012-06-12T01:31:56.000+0000", "updated": "2012-06-12T01:32:54.000+0000" }, { "id": "241426", "author": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Hi,\n\nWith a test the the latest TISDK 3.0.2 or CI, this issue was not reproducible. Can you please test our latest SDK? If the problem exists, you can provide us some log files.\n\nThanks,", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-03-08T22:41:52.000+0000", "updated": "2013-03-08T22:41:52.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }