Facebook Twitter Gplus YouTube RSS
magnify
Home iPhone Appcelerator Titanium Custom URL Scheme in iPhone and Android
formats

Appcelerator Titanium Custom URL Scheme in iPhone and Android

Some times we have to call our app from another application which we have control (Both are our Apps). Even sometimes we need to provide option to users to open native app from our website page. For example calling mail composer using mailto: <a href=”mailto:mailid@mail.com”>Open email composer</a> . When End user click on this link it will open native email composer. same thing we can also do in our app also. For example <a href=”appid://”>open my app</a> it will open from browser.

Even we can also open from another app using Titanium api, Ti.Platform.openURL('appid://'); . For understanding better we use this code to open Maps from our app Ti.Platform.openURL('Maps://');

open URL scheme

open URL scheme

info.plist file:

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.shareourideas.urlscheme</string>
<key>CFBundleURLSchemes</key>
<array>
<string>[app scheme here]</string>
</array>
</dict>
</array>

To add URL scheme just build app first time. It will create info.plist file inside Build/iPhone folder. Just copy that file and paste in root folder. And just check with CFBundleURL Schemes . Just add url scheme inside (here it’s urlscheme). Start running app and just open Safari in iPhone and type urlscheme:// in address bar and Go. It will open our application.

We can also handle url parameters. For example urlscheme://id=007&name=ShareOurideas . We can get this parameters values from Titanium.App.getArguments() JSON.

Titanium.App.getArguments to get parameters

Titanium.App.getArguments to get parameters

Same thing we can do in Android also but we need to follow some steps same like iPhone. Just check with this post to add URL scheme in Android app too.

Enjoy while coding..!

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
1 Comment  comments