Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2679] Issue with Facebook Login and Navigation Group

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionWon't Fix
Resolution Date2012-08-14T08:02:45.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsfacebook, ios, navigationGroup
ReporterMichael M
AssigneeMauro Parra-Miranda
Created2012-08-12T04:57:29.000+0000
Updated2016-03-08T07:41:47.000+0000

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: app.js Ti.App.Properties.setString("fbAccess","login"); Ti.Facebook.appid = 'xxxxxxxxxx'; Ti.Facebook.permissions = ['publish_stream','offline_access','email']; //Ti.Facebook.forceDialogAuth = false; Ti.include('preLogin.js'); loginFBC.js Ti.Facebook.addEventListener('login', function(e) { Ti.API.info("inside login"); if ((e.success) && (Ti.App.Properties.getString("fbAccess")=="login")) { Ti.API.info("inside if"); navGroup.close(); Ti.include('preLogin.js'); }}); preLogin.js var buttonLoginFB = Titanium.UI.createButton({ top: "90%", width: "70%", height: "12%"}); var preLoginWin = Titanium.UI.createWindow({ titleImage:'/icons/logoForBar.png', title:"Back", backgroundColor:'#fff', barColor:'00aeef', }); var buttonLogin = Titanium.UI.createButton({ title: 'Login', top: "30%", width: "70%", height: "12%", opacity:1 }); var buttonRegister = Titanium.UI.createButton({ title: 'Register', top: "60%", width: "70%", height: "12%", opacity:1 }); var navGroup = Ti.UI.iPhone.createNavigationGroup({ window:preLoginWin }); preLoginWin.add(buttonLogin,buttonRegister,buttonLoginFB); var main = Ti.UI.createWindow(); main.add(navGroup); main.open(); Ti.include('/loginFBC.js'); //include the preLoginC.js that holds the code for the buttons listeners Ti.include('/preLoginC.js'); and the preLoginC.js buttonLoginFB.addEventListener("click", function(e) { Ti.API.info("button"); Ti.Facebook.logout(); Ti.Facebook.appid = 'xxxxxxxxxxx'; Ti.Facebook.permissions = ['publish_stream','offline_access','email']; //Ti.Facebook.forceDialogAuth = false; Ti.Facebook.authorize(); });

Comments

  1. Davide Cassenti 2012-08-14

    Hello, I am unable to replicate your bug. I would recommend not to use Ti.include, though, but to use the CommonJS format.
  2. Michael M 2012-08-14

    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?
  3. Davide Cassenti 2012-08-14

    Take a look at this guide in order to work with CommonJS: https://wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium Hope it helps.

JSON Source