2013年5月24日 星期五

Pass arguments to app when launch or resume


1. To read argument when app is launched, use
Ti.App.getArguments(); 
in app.js

2. To read argument when app is resumed (put into foreground again), use the same line inside
'resumed' event ( NOT 'resume' ) :

Ti.App.addEventListener('resumed', function(e){
       Ti.App.getArguments();
});


To read calling URL argument,
var launchObj = Ti.App.getArguments();
if(launchObj.hasOwnProperty('url')){
   var url = launchObj.url;
   var param = url.substring(url.indexOf('//')+2, url.length);
   //e.g. myall://xyz , param = xyz  
}

沒有留言:

張貼留言