Tuesday, October 4, 2011

Getting directions from an iOS FireMonkey application

Q: How do you get directions on the iPhone from a FireMonkey application?
A: By opening a URL formatted like so - http://maps.google.com/maps?saddr=FROM&daddr=TO

unit Unit1;

{$IFDEF FPC}
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
{$ENDIF}

interface

uses
SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
FMX_Dialogs
{$IFDEF FPC}
, iPhoneAll
{$ENDIF}
;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);
var
LocationFrom, LocationTo, URL : String;
begin
{$IFDEF FPC}
LocationFrom := 'Current+Location';
LocationTo := 'Scotts+Valley+Drive,+Scotts+Valley,+CA';
URL := 'http://maps.google.com/maps?saddr='+LocationFrom+'&daddr='+LocationTo;
UIApplication.sharedApplication.openUrl(NSUrl.URLWithString(NSSTR(PChar(URL)))));
{$ENDIF}
end;

end.

Display a map from an iOS FireMonkey application

Q: How do you display a map on the iPhone using FireMonkey?
A: By opening a URL formatted like so - http://maps.google.com/maps?q=LOCATION

Below is a short snippet that will do show a map of the Embarcadero Scotts Valley offices.

Enjoy!

unit Unit1;

{$IFDEF FPC}
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
{$ENDIF}

interface

uses
SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
FMX_Dialogs
{$IFDEF FPC}
, iPhoneAll
{$ENDIF}
;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Location : String;
begin
{$IFDEF FPC}
Location := 'http://maps.google.com/maps?q=5617+Scotts+Valley+Drive,+Scotts+Valley,+CA';
UIApplication.sharedApplication.openUrl(NSUrl.URLWithString(NSSTR(PChar(Location))));
{$ENDIF}
end;

end.

Opening a URL from an iOS FireMonkey application

Q: How do you open a URL in Safari on the iPhone using FireMonkey?
A: You use UIApplication.sharedApplication.openUrl

Below is a very simple unit that will do the code. Just create an iOS app with one button and add the following code to the unit.

unit Unit1;

{$IFDEF FPC}
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
{$ENDIF}

interface

uses
SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
FMX_Dialogs
{$IFDEF FPC}
, iPhoneAll
{$ENDIF}
;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
// Open a URL
{$IFDEF FPC}
UIApplication.sharedApplication.openUrl(NSUrl.URLWithString(NSSTR(PChar('http://blogs.embarcadero.com/ao'))));
{$ENDIF}
end;

end.

Dialing a phone number from an iOS FireMonkey application

Q: How do you dial a phone number from an iOS application?
A: You open a URL with the following format - tel://123456789

Below is a very simple Delphi iOS unit that will do the trick.

Notice the {$IFDEF FPC} blocks that ensure that the application also compiles and is "testable" on Windows.

Enjoy!
unit Unit1;

{$IFDEF FPC}
{$mode objfpc}{$H+}
{$modeswitch objectivec1}
{$ENDIF}

interface

uses
SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
FMX_Dialogs
{$IFDEF FPC}
, iPhoneAll
{$ENDIF}
;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
// Dial a phone number
{$IFDEF FPC}
UIApplication.sharedApplication.openUrl(NSUrl.URLWithString(NSSTR(PChar('tel://18005551212'))));
{$ENDIF}
end;

end.

Thursday, September 29, 2011

FireMonkey performance on iOS device 2x-3x FASTER with Update 1

Great news!

FireMonkey iOS apps built with the RTM version of RAD Studio XE2 were a little sluggish. The great news is that with Update 1 that was just released, the performance has improved significantly!

We will of course continue updating and improving performance wherever possible as soon as possible.

Get Update 1 here.

Enjoy!

Tuesday, September 6, 2011

My RAD Studio XE2 Launch Stops

The RAD Studio XE2 World Tour is in full swing. All the stops are listed here.

I launched the new product in Orange County and Los Angeles last week, and the feedback has been amazing! The sign-ups for the events is close to double from what it was last year, and people are very impressed with what we've packed into this release!

It's pure joy showing off 64-bit, FireMonkey, MacOSX, iOS, VCL Styles, LiveBindings, etc, etc!

Here's the rest of my schedule:

9/7 Portland, OR
9/8 Seattle, WA
9/12-14 Delphi Live
9/15 San Diego, CA
9/17 Washington, DC
9/20 Salt Lake City, UT
9/21 Phoenix, AZ
9/22 Sacramento, CA
9/24 Newark, NJ

Enjoy! :)

Thursday, June 23, 2011

AppWave is here!

AppWave is your private PC app store that provides a mobile-like experience for Windows software. Learn how it can help you boost productivity.

Productivity is increased. Friction is eliminated. Discovering and launching apps is simple and quick.


AppWave is a free, enterprise-grade private PC app store that provides a mobile-like app experience for PC software applications. With AppWave, you can quickly discover and run PC apps. Say goodbye to desktop software installations, manual upgrade processes, and confusing license tracking. Now anyone can experience PC apps the way they should be. Friction-free.

Surf the AppWave here!