iOS OpenURL – Not just for HTTP URLs

  

Anders just recently blogged about how to open Safari from your iOS Delphi app and showed how to incorporate Cleggy’s Apple.Utils.pas unit to make it just as simple as:
OpenURL(‘http://www.embaracdero.com’);
The interesting point is now, that this would also work for other apps. If you want to open the iPhone Messenger for example, then just do this:
OpenURL(‘sms:1-408-555-1212′);
This also works with 3rd party Apps, you can open the Facebook app like this:
OpenURL(‘fb://profile’);
But what if the App is not installed or not available (like on the iOS simulator)? OpenURL will do just nothing, which is kind of stupid, you might want to do something as alternative probably.
For that reason there is CanOpenURL (which is not yet in Cleggy’s unit). That just returns true or false indicating if the required app is available. This is how you would implement/call it –
Update: CanOpenURL is now in DX.Library

uses

Apple.Utils;
function CanOpenURL(AURL: string):boolean;
begin
result := SharedApplication.canOpenURL(StringToNSUrl(AURL));
end;

Here are a couple of links where you find information about available URL schemes:

Apple URL Schemes
Misc URL Schemes from AKOSMA Wiki

Tweet This!

Share this on del.icio.us

Digg this!

Share this on Reddit

Get Shareaholic

Comments are closed.