{ "id": "99052", "key": "AC-2679", "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": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2012-08-14T08:02:45.000+0000", "created": "2012-08-12T04:57:29.000+0000", "labels": [ "facebook", "ios", "navigationGroup" ], "versions": [], "issuelinks": [], "assignee": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "updated": "2016-03-08T07:41:47.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": "I have a navigation group that is used for login. If the user is logged in succesfully the app closes the navigation group (with navGroup.close which I assume that this is destroy the navigation group) and create a tab group. When the user logged out the tabgroup is closed and the navigation group is created again. The issue is that the facebook login button(which is on navigation group) is works fine the 1st time that the navgroup is created but the second time is execute the 'login' listener 2 times and the 3d time 3 times and so on. Here is a simplified code that generate this bug:\r\n\r\napp.js\r\n\r\nTi.App.Properties.setString(\"fbAccess\",\"login\");\r\nTi.Facebook.appid = 'xxxxxxxxxx';\r\nTi.Facebook.permissions = ['publish_stream','offline_access','email'];\r\n//Ti.Facebook.forceDialogAuth = false;\r\nTi.include('preLogin.js');\r\n\r\n\r\nloginFBC.js\r\n\r\nTi.Facebook.addEventListener('login', function(e) {\r\n\r\n Ti.API.info(\"inside login\"); \r\n\r\n if ((e.success) && (Ti.App.Properties.getString(\"fbAccess\")==\"login\")) {\r\n Ti.API.info(\"inside if\"); \r\n\r\n navGroup.close();\r\n Ti.include('preLogin.js');\r\n }});\r\n\r\n\r\n\r\npreLogin.js\r\n\r\nvar buttonLoginFB = Titanium.UI.createButton({\r\n top: \"90%\",\r\n width: \"70%\",\r\n height: \"12%\"});\r\n\r\nvar preLoginWin = Titanium.UI.createWindow({ \r\n titleImage:'/icons/logoForBar.png', \r\n title:\"Back\",\r\n backgroundColor:'#fff',\r\n barColor:'00aeef',\r\n });\r\nvar buttonLogin = Titanium.UI.createButton({\r\n title: 'Login',\r\n top: \"30%\",\r\n width: \"70%\",\r\n height: \"12%\",\r\n opacity:1\r\n });\r\n\r\nvar buttonRegister = Titanium.UI.createButton({\r\n title: 'Register',\r\n top: \"60%\",\r\n width: \"70%\",\r\n height: \"12%\",\r\n opacity:1\r\n\r\n });\r\n\r\n\r\n\r\n\r\n var navGroup = Ti.UI.iPhone.createNavigationGroup({\r\n window:preLoginWin\r\n });\r\n\r\n preLoginWin.add(buttonLogin,buttonRegister,buttonLoginFB);\r\n\r\n var main = Ti.UI.createWindow();\r\n\r\n main.add(navGroup); \r\n main.open();\r\n\r\nTi.include('/loginFBC.js');\r\n//include the preLoginC.js that holds the code for the buttons listeners\r\nTi.include('/preLoginC.js');\r\n\r\n\r\n\r\n\r\nand the preLoginC.js\r\n\r\nbuttonLoginFB.addEventListener(\"click\", function(e) {\r\n\r\nTi.API.info(\"button\");\r\n\r\nTi.Facebook.logout();\r\nTi.Facebook.appid = 'xxxxxxxxxxx';\r\nTi.Facebook.permissions = ['publish_stream','offline_access','email'];\r\n//Ti.Facebook.forceDialogAuth = false;\r\nTi.Facebook.authorize();\r\n\r\n\r\n});", "attachment": [], "flagged": false, "summary": "Issue with Facebook Login and Navigation Group", "creator": { "name": "mavris13", "key": "mavris13", "displayName": "Michael M", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mavris13", "key": "mavris13", "displayName": "Michael M", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Mac OS X, App for iPhone", "comment": { "comments": [ { "id": "214279", "author": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hello,\r\n\r\nI am unable to replicate your bug. I would recommend not to use Ti.include, though, but to use the CommonJS format.", "updateAuthor": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-08-14T03:41:24.000+0000", "updated": "2012-08-14T03:41:24.000+0000" }, { "id": "214281", "author": { "name": "mavris13", "key": "mavris13", "displayName": "Michael M", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I found the issue. Each time that I was using Ti.include /prelogin.js it was adding again the event listeners for facebook. Is there any official way/guide(from Appcelerator) how to use commonjs?", "updateAuthor": { "name": "mavris13", "key": "mavris13", "displayName": "Michael M", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-14T04:22:01.000+0000", "updated": "2012-08-14T04:22:01.000+0000" }, { "id": "214300", "author": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "body": "Take a look at this guide in order to work with CommonJS: https://wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium\r\n\r\nHope it helps.", "updateAuthor": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-08-14T08:02:45.000+0000", "updated": "2012-08-14T08:02:45.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }