this Just in

Home  >>  Blog  >>  Post Detail

Opening native apps using Appcelerator Titanium

Ever needed to open a native app from your Appcelerator Titanium project? Read below for a simple method I put together.

The below method works for Android and iOS. My particular method was used to open the native twitter client.

// Enclose in Try / Catch in case of Android try {      // canOpenURL only works in iOS      if (Ti.Platform.canOpenURL(e.rowData.tweetUrl)){           // Open the native twitter client url: twitter://status?id=statusidnumber           Ti.Platform.openURL(e.rowData.tweetUrl);      } else {           // If it can't open the twitter client open the twitter site: http://twitter.com/user/statuses/statusidnumber           Ti.Platform.openURL(e.rowData.fallbackUrl);      } } catch (err) {      // Android will catch an error because it can't call canOpenURL      Ti.API.error(err);      Ti.Platform.openURL(e.rowData.fallbackUrl); }

Every app uses a unique URL scheme. If you don't know the URL scheme for the app you're trying to open, check out http://handleopenurl.com/ for a great reference of iOS URL schemes.

comments powered by Disqus

Tags

Archive


Like what you see? Have a question for us? Contact Us.

Call us toll free at 1.888.262.9212