Hello,
I recently submitted what I thought was a simple application to Apple, however it was rejected for "App does not load passed the launch screen." My SDK is 2.0.1GA2 & here is my app.js. Does anyone see anything obvious because on my device, once installed, the app runs without issue.
It's a simple webview app, that has tabs that go to different external websites.
var network = Titanium.Network; // NETWORK CONNECTION CHECK if (network.online == false) { Ti.UI.createAlertDialog({title:'No Data Network', message:'Please connect to a data network.', buttonNames:['Close']}).show(); } // this sets the background color of the master UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#000'); // create tab group var tabGroup = Titanium.UI.createTabGroup({id:'tabGroup1'}); // // create activity tab and root window // var win1 = Titanium.UI.createWindow({ url:'activity.js', titleImage: 'images/titlebar.png', barImage: 'images/titlebarbg.png' }); var tab1 = Titanium.UI.createTab({ icon:'images/activity.png', titleid:'Activity', window:win1 }); // // create discussions tab // var win2 = Titanium.UI.createWindow({ url:'discussion.js', titleImage: 'images/titlebar.png', barImage: 'images/titlebarbg.png' }); var tab2 = Titanium.UI.createTab({ icon:'images/discussion.png', titleid:'Discussions', window:win2 }); // // create calendar tab // var win3 = Titanium.UI.createWindow({ url:'calendar.js', titleImage: 'images/titlebar.png', barImage: 'images/titlebarbg.png' }); var tab3 = Titanium.UI.createTab({ icon:'images/calendar.png', titleid:'Calendar', window:win3 }); // // create members tab // var win4 = Titanium.UI.createWindow({ url:'members.js', titleImage: 'images/titlebar.png', barImage: 'images/titlebarbg.png' }); var tab4 = Titanium.UI.createTab({ icon:'images/members.png', titleid:'Members', window:win4 }); // // create more tab // var win5 = Titanium.UI.createWindow({ url:'more.js', titleImage: 'images/titlebar.png', barImage: 'images/titlebarbg.png' }); var tab5 = Titanium.UI.createTab({ icon:'images/more.png', titleid:'More', window:win5 }); // // add tabs // tabGroup.addTab(tab1); tabGroup.addTab(tab2); tabGroup.addTab(tab3); tabGroup.addTab(tab4); tabGroup.addTab(tab5); tabGroup.addEventListener('open',function() { // set background color back to white after tab group transition Titanium.UI.setBackgroundColor('#fff'); }); tabGroup.setActiveTab(0); // open tab group with a transition animation tabGroup.open({ transition: Titanium.UI.iPhone && Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT }); // setTimeout(function() // { // tabGroup.close({ // transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT // }); // },2000); // // TAB GROUP EVENTS // var messageWin = Titanium.UI.createWindow({ height:30, width:250, bottom:70, borderRadius:10, touchEnabled:false, orientationModes : [ Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT, Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT ] }); var messageView = Titanium.UI.createView({ id:'messageview', height:30, width:250, borderRadius:10, backgroundColor:'#000', opacity:0.7, touchEnabled:false }); var messageLabel = Titanium.UI.createLabel({ id:'messagelabel', text:'', color:'#fff', width:250, height:'auto', font:{ fontFamily:'Helvetica Neue', fontSize:13 }, textAlign:'center' }); messageWin.add(messageView); messageWin.add(messageLabel); // // CREATE CUSTOM LOADING INDICATOR // var indWin = null; var actInd = null; function showIndicator() { if (Ti.Platform.osname != 'android') { // window container indWin = Titanium.UI.createWindow({ height:150, width:150 }); // black view var indView = Titanium.UI.createView({ height:150, width:150, backgroundColor:'#000', borderRadius:10, opacity:0.8 }); indWin.add(indView); } // loading indicator actInd = Titanium.UI.createActivityIndicator({ style:Titanium.UI.iPhone && Titanium.UI.iPhone.ActivityIndicatorStyle.BIG, height:30, width:30 }); if (Ti.Platform.osname != 'android') { indWin.add(actInd); // message var message = Titanium.UI.createLabel({ text:'Loading', color:'#fff', width:'auto', height:'auto', font:{fontSize:20,fontWeight:'bold'}, bottom:20 }); indWin.add(message); indWin.open(); } else { actInd.message = "Loading"; } actInd.show(); } function hideIndicator() { actInd.hide(); if (Ti.Platform.osname != 'android') { indWin.close({opacity:0,duration:500}); } } // // Add global event handlers to hide/show custom indicator // Titanium.App.addEventListener('show_indicator', function(e) { Ti.API.info("IN SHOW INDICATOR"); showIndicator(); }); Titanium.App.addEventListener('hide_indicator', function(e) { Ti.API.info("IN HIDE INDICATOR"); hideIndicator(); }); // //add iphone specific options // if (Titanium.Platform.name == 'iPhone OS') { Ti.include("notifications.js"); }
2 Answers
Accepted Answer
Couple of thoughts on the flow of the code above.
- Check for network
- Display a dialog for the user if no network.
- Build UI
Its better to build the base UI, tabs/windows/etc and alert the user only if there is a problem loading the remote page by using one of the event handlers for your web view.
- Using the url: param to load scripts into your windows is not considered best practice as it loads them in a separate context.
- commonJS is now considered best practice CommonJS Modules in Titanium, Forging Titanium Episode 1: CommonJS Modules
Well, for those who provided good feedback thank you. Despite it going to an external page, I am utilizing push notifications. I'm hoping I found the issue and it has been resubmitted to Apple.
Your Answer
Think you can help? Login to answer this question!