<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>myappurlschemename</string> </array> </dict>
Be sure to replace the myappurlschemename with the actual name of your app or at least the name of the scheme you want to register and use to launch your app. It gets used to launch the app in a URL like this: myappurlschemename://mypage?myname=myvalue You can paste myappurlschemename://mypage?myname=myvalue into Safari to test launching your app. There is also a good tutorial here for XCode so you can see how it works from the XCode side.
Next up you need to add some code to your app to handle the TApplicationEvent.OpenURL event. You can do this with the following code. You will want to add FMX.Platform to your uses section and you will want to start listening to the FMXApplicationEventService in your TMainForm.OnCreate event:
uses FMX.Platform, {$IFDEF IOS} FMX.Platform.iOS {$ENDIF} procedure TMainForm.FormCreate(Sender: TObject); var FMXApplicationEventService: IFMXApplicationEventService; begin if TPlatformServices.Current.SupportsPlatformService (IFMXApplicationEventService, IInterface(FMXApplicationEventService)) then FMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent); end; function TMainForm.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean; begin case AAppEvent of TApplicationEvent.OpenURL: begin {$IFDEF IOS} LaunchURL := TiOSOpenApplicationContext(AContext).URL; {$ENDIF} end; end; Result := True; end;
When the event executes and your app is launched the LaunchURL string will get filled with the URL that the app was launched using. You can then parse the LaunchURL string to get the various parameters out of it. You’ll need IdURI and IdGlobal in your uses section for the below code. Here is the sample code to parse the URL:
var Params: TStringList; MyValue: String; begin if LaunchURL<>'' then begin Params := TStringList.Create; try URI := TIdURI.Create(LaunchURL); try Params.Delimiter := '&'; Params.StrictDelimiter := true; // Path = URI.Path Params.DelimitedText := URI.Params; finally URI.Free; end; for I := 0 to Params.Count -1 do begin Params.ValueFromIndex[I] := StringReplace(Params.ValueFromIndex[I], '+', ' ', [rfReplaceAll]); Params.ValueFromIndex[I] := TIdURI.URLDecode(Params.ValueFromIndex[I], IndyTextEncoding_UTF8()); end; MyValue := Params.Values['myname']; finally Params.Free; end; LaunchURL := ''; end; end;