{ "id": "146168", "key": "AC-1008", "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": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2015-09-30T00:42:15.000+0000", "created": "2015-03-24T16:52:51.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:37:20.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": [], "description": "The application I have developed requires a customized contacts list built by calling:\r\n\r\nTi.Contacts.getAllPeople();\r\n\r\nBecause some users have duplicate contacts, multiple linked contacts I de-duplicate the list and store a copy of the contacts with the app. This makes getting the contacts list much faster.\r\n\r\nHowever, I need to listen for changes to the contacts and fire off an update to the cached list - most typical is someone adding a contact on-the-fly when using the app.\r\n\r\nI have implemented the following in app.js:\r\nTi.Contacts.addEventListener('reload', function(e) { ... });\r\n\r\nIt works just fine until the app is 'swipe quit'. In other words if:\r\n-- Launch app, go to contacts, change contact, go back to app, event is fired just fine\r\n\r\nAt any point in time, quitting the app seems to consume the event listener and it will never work again until the app is deleted and reinstalled -- regardless of whether the event listener is added.", "attachment": [], "flagged": false, "summary": "Ti.Contacts Reload Event Listener Not Working Properly", "creator": { "name": "timchristensen", "key": "timchristensen", "displayName": "Tim Christensen", "active": true, "timeZone": "America/Denver" }, "subtasks": [], "reporter": { "name": "timchristensen", "key": "timchristensen", "displayName": "Tim Christensen", "active": true, "timeZone": "America/Denver" }, "environment": "iOS, 3.5.1, Studio 3.4.1", "comment": { "comments": [ { "id": "347261", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Hi,\r\n\r\nPlease provide a simple test case to reproduce your problem. That will be helpful to address the problem you have.\r\nHere is the guide about [how to create a test case|http://docs.appcelerator.com/titanium/3.0/#!/guide/How_to_Submit_a_Bug_Report-section-29004732_HowtoSubmitaBugReport-CreatingaTestCase]\r\n\r\nRegards,\r\nShuo", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2015-03-25T08:40:42.000+0000", "updated": "2015-03-25T08:40:42.000+0000" }, { "id": "347368", "author": { "name": "timchristensen", "key": "timchristensen", "displayName": "Tim Christensen", "active": true, "timeZone": "America/Denver" }, "body": "I figured out what the issue is, not sure if it is a bug or a feature -- the event only fires AFTER Ti.Contacts.getAllPeople() is called.\r\n\r\nTo test:\r\n\r\n1. Launch this\r\n2. Go to contacts and change one and save\r\n3. Resume app\r\n\r\n(function()\r\n\t{\r\n\tvar reloadCounter = 0;\r\n\t\r\n\tfunction reloadContacts() {\r\n\t\treloadCounter++;\r\n\t\tTi.API.info('Reload Contacts ' + reloadCounter);\r\n\t\t}\r\n\t\t\r\n\tfunction addReloadListener() {\r\n\t\tTi.API.info('Adding Reload Listener');\r\n\t\tTi.Contacts.addEventListener('reload', reloadContacts);\r\n\t\t\r\n\t\t// This has to be called before the listener will work\r\n\t\t// Either before or after it is added\r\n\t\t//Ti.Contacts.getAllPeople();\r\n\t\t}\r\n\t\t\r\n\tif (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED) {\r\n\t\taddReloadListener();\r\n\t\t}\r\n\telse if(Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_UNKNOWN)\r\n\t\t{\r\n\t\tTi.Contacts.requestAuthorization(function(e) {\r\n\t\t\tif(e.success) {\r\n\t\t\t\taddReloadListener();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t})();", "updateAuthor": { "name": "timchristensen", "key": "timchristensen", "displayName": "Tim Christensen", "active": true, "timeZone": "America/Denver" }, "created": "2015-03-26T00:04:40.000+0000", "updated": "2015-03-26T00:04:40.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }