Two part question (related): 1.I essentially have a modal window (initialWindow) that opens up immediately after my app is launched and is only closed after my facebook login is confirmed. Once confirmed, the window disappears (like I want it to - think apps with required social media login), but the problem is that the window has a tab associated with it. This means that there is a meaningless tab in the tab bar that has no purpose. I have experimented with various methods, but my current code seems to be the only one that is working correctly.
2.I have tried to associate a function with the initialWindow that states, on app launch, if the user has already been authorized and is signeded in, prevent the initialwindow from opening. Unfortunately, I don't believe I am implementing the call the right way or might not have the function in the right file.
app.js
var initialWindow = Titanium.UI.createWindow({ url: 'initialWindow.js', }); if(Ti.Facebook.loggedIn = false){ initialWindow.open() } else { initialWindow.close() }; Titanium.UI.setBackgroundColor('#000'); // create tab group var tabGroup = Titanium.UI.createTabGroup(); var initial = Ti.UI.createTab({ window:initialWindow, }); // // create base UI tab and root window // var daily = Ti.UI.createWindow({ backgroundColor: '#fff', url:'daily.js' }) var tab1 = Titanium.UI.createTab({ icon:'', title:'Tab 1', window:dailySpecials }); // // create controls tab and root window // var win2 = Titanium.UI.createWindow({ title:'Tab 2', backgroundColor:'#fff', }); var tab2 = Titanium.UI.createTab({ icon:'KS_nav_views.png', color:'#000', window:win2 }); var label2 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 2', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win2.add(label2); // // add tabs // tabGroup.addTab(initial); tabGroup.addTab(tab1); tabGroup.addTab(tab2); // open tab group tabGroup.open();
initialWindow.js
var Cloud = require('ti.cloud'); Titanium.Facebook.appid = "xxxxxxxx";//Production Titanium.Facebook.permissions = ['publish_stream', 'read_stream']; var win = Ti.UI.createWindow({ navBarHidden:true, tabBarHidden:true, backgroundColor:'#fff' }); var fbSignupBtn = Ti.Facebook.createLoginButton({ bottom: 50, style : Ti.Facebook.BUTTON_STYLE_WIDE }); win.add(fbSignupBtn); Titanium.Facebook.addEventListener('login', function(e) { if (e.success) { Cloud.SocialIntegrations.externalAccountLogin({ type : 'facebook', token : Ti.Facebook.accessToken }, function(e) { if (e.success) { var user = e.users[0]; Ti.API.info('User = ' + JSON.stringify(user)); Ti.App.Properties.setString('currentUserId', user.id); win.close(); } else { alert('Error: ' + ((e.error && e.message) || JSON.stringify(e))); } }); } else if (e.error) { alert("Error = " + e.error); } else if (e.cancelled) { alert("cancelled"); } }); win.open();