{ "id": "159654", "key": "MOD-2249", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10034", "key": "MOD", "name": "Appcelerator Modules", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-07-28T19:26:48.000+0000", "created": "2016-04-18T18:49:00.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-08-06T17:37:00.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": [], "description": "* Create a native iOS module\r\n* In the module, fire an event, as seen below:\r\n{code:objc}\r\n- (void) imageCaptured:(NSNotification *) notification\r\n{\r\n NSLog(@\"[INFO] module notified of image capture event\");\r\n if ([self _hasListeners:'imageCaptured'])\r\n [self fireEvent:'imageCaptured' withObject:notification.userInfo];\r\n else\r\n NSLog(@\"[INFO] if an image is captured, and there is no one there to listen for it, does an event get fired?\");\r\n}\r\n{code}\r\n\r\n* In Appcelerator, listen for this event:\r\n{code:js}\r\nmymodule.addEventListener('imageCaptured', function(e){\r\n Ti.API.info('image capture event caught in JS.);\r\n});\r\n{code}\r\n\r\n* Sometimes the event will catch. You will see both lines in the console. Other times, you will see the first line in the console, but nothing else. No error, and no response in JS. \r\n\r\n\r\n\r\nhttp://stackoverflow.com/questions/36655410/appcelerator-module-events-stop-firing?noredirect=1#comment60966343_36655410", "attachment": [], "flagged": false, "summary": "Appcelerator module events stop firing", "creator": { "name": "falt86", "key": "falt86", "displayName": "derick alt", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "falt86", "key": "falt86", "displayName": "derick alt", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Appcelerator Studio 5.2.2 and Xcode 7.3", "closedSprints": [ { "id": 925, "state": "closed", "name": "2017 Sprint 15 SDK", "startDate": "2017-07-16T14:40:47.191Z", "endDate": "2017-07-30T14:40:00.000Z", "completeDate": "2017-07-31T16:15:09.335Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "383333", "author": { "name": "falt86", "key": "falt86", "displayName": "derick alt", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I was able to work around this issue for the time being by moving all events to my custom view, using [[self proxy] fireevent...]", "updateAuthor": { "name": "falt86", "key": "falt86", "displayName": "derick alt", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-04-20T12:49:35.000+0000", "updated": "2016-04-20T12:49:35.000+0000" }, { "id": "383347", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, \r\n\r\nThanks for creating the JIRA ticket. Please attach the module project to this ticket for us to test it in our environment. It will be helpful to understand the issue properly if we were to investigate the project code. Also, please provide the full list of steps to follow. \r\n\r\nRegards,\r\nSharif.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2016-04-20T14:13:17.000+0000", "updated": "2016-04-20T14:13:17.000+0000" }, { "id": "383378", "author": { "name": "falt86", "key": "falt86", "displayName": "derick alt", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I am not permitted to share the full source code, as it is proprietary. The steps to reproduce should be quite simple.\r\n1. Create a native iOS module\r\n2. Create a view and view proxy in the module\r\n3. From the view, post a notification like so... \"[[NSNotificationCenter defaultCenter] \r\n postNotificationName:@\"TestNotification\" \r\n object:self];\"\r\n4. In your module, add an observer for that notification, that will fire off an event. like so... \"[[NSNotificationCenter defaultCenter] addObserver:self\r\n selector:@selector(receiveTestNotification:) \r\n name:@\"TestNotification\"\r\n object:nil];\"\r\n-(void)receiveTestNotification:(NSNotification*)notification\r\n{\r\nNSLog(@\"[INFO] module notified \"); \r\n[self fireEvent:'test' withObject:notification.userInfo]; \r\n}\r\n5. add a listener in JS for this event.\r\n\r\nThe line \"module notified\" will fire every time, telling you that the notification was processed and caught by the module. The event in JS will randomly not fire.", "updateAuthor": { "name": "falt86", "key": "falt86", "displayName": "derick alt", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-04-20T16:51:40.000+0000", "updated": "2016-04-20T16:51:40.000+0000" }, { "id": "383943", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, \r\n\r\nPlease create a module only with the section that causing the issue. And provide the module in the ticket. You need to provide a test case which we can use to reproduce the issue. We need a test case and steps to reproduce the issue.\r\n\r\nRegards,\r\nSharif.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2016-04-26T16:11:00.000+0000", "updated": "2016-04-26T16:11:00.000+0000" }, { "id": "425038", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "This is no Titanium issue but an issue with the way you implement the module. The reason why it is not firing is a race-condition caused by posting the notification and sending the event asynchronously. An easy fix would be to have a protocol that is implemented by the module and triggered by the view, that's how there won't be any issues. We had similar problems in the {{MediaModule}} core-class and fixed it by waiting until the actual action was done and fire the event afterwards. It might be worth checking the source [here|https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/MediaModule.m].", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-07-28T19:26:49.000+0000", "updated": "2017-07-28T19:26:49.000+0000" }, { "id": "439907", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as invalid. If incorrect, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T17:37:00.000+0000", "updated": "2018-08-06T17:37:00.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }