Looking for away to make sure your uses have upgraded to the latest version of your app? Using the AppStoreHelpers object within the benCoding.iOS.Tools module you can easily query the Apple AppStore for the latest version. You are then a simple version compare away from having the information needed to prompt your user to upgrade or version specific service calls.
Show me an example
var tools = require('bencoding.ios.tools'); var appStoreHelpers = tools.createAppStoreHelpers(); function queryResults(e){ Ti.API.info(JSON.stringify(e)); Ti.API.info("success = " + e.success); Ti.API.info("appStoreVersion = " + e.appStoreVersion); Ti.API.info("appID = " + e.appID); Ti.API.info("code = " + e.code); Ti.API.info("installedVersion = " + e.installedVersion); var hasUpdate = (parseFloat(e.appStoreVersion) > parseFloat(e.installedVersion)); if(hasUpdate){ var alert = Ti.UI.createAlertDialog({ title:'Update now', message:'There is a new version available. Do you want to download now?', buttonNames : ['OK','Cancel'] }); alert.addEventListener('click', function(y){ if(y.index == 0){ appStoreHelpers.launch(queryITunesID); } }); alert.show(); } }; //Let's pretend we are angry birds var queryITunesID = '409807569'; //Call the check version method appStoreHelpers.versionCheck(queryITunesID,queryResults);
How does it work?
You can look-up the version information for an iTunes Id by making a service call to http://itunes.apple.com/lookup. For example, you can get the latest information about Angry Birds by using http://itunes.apple.com/lookup?id=409807569
How do I get my iTunes Id?
To find your iTunes Id open iTunes and go to your app. Right click on the App’s iTunes coverart and select the Copy Link option. For example, if you do this on Angry Birds you will receive the following url https://itunes.apple.com/us/app/angry-birds-free/id409807569?mt=8.
The section after the id and before the question mark is your iTunes Id. Using our Angry Bird’s example their iTunes Id would be 409807569. This is the value you will want to use when launching or performing a version check.
Where can I get it?
The benCoding.iOS.Tools module is available on Github at https://github.com/benbahrenburg/benCoding.iOS.Tools