weabow 6 Posted September 29, 2023 Hi there, I would like to open my app (windows, macos, ios, android & linux) clicking on a link (inside an email for example), and pass to the app a parameter which is inside the link. Is it possible ? Regards Share this post Link to post
Lars Fosdal 1791 Posted September 29, 2023 On Windows, there is the concepts of file type associations, URL handlers, etc. On Android, you must use intents. MacOS and iOS also has intents, but I don't know if FMX support them? Linux - not sure. Share this post Link to post
weabow 6 Posted September 29, 2023 Thanks. For Windows I know associations, but as I know, it needs to have a file. I've already implemented it and it runs fine with the file. But the need I have is to use a link, something like Zoom... It's a good news to know that on MacOs it can run. On mobiles, I've been told that it can run too, but on Apple maybee there are restrictions ? Linux is not in a hurry for me. Share this post Link to post
evolplus 1 Posted October 5, 2023 On 9/29/2023 at 7:51 PM, weabow said: Thanks. For Windows I know associations, but as I know, it needs to have a file. I've already implemented it and it runs fine with the file. But the need I have is to use a link, something like Zoom... It's a good news to know that on MacOs it can run. On mobiles, I've been told that it can run too, but on Apple maybee there are restrictions ? Linux is not in a hurry for me. I think what you need is register a URL scheme for your app on Windows as follows: procedure RegisterURLScheme(protocol: string); var reg: TRegistry; begin reg := TRegistry.Create; reg.RootKey := HKEY_CURRENT_USER; reg.OpenKey('Software\Classes\' + protocol, true); reg.WriteString('', 'URL:' + protocol); reg.WriteString('URL Protocol', ''); reg.CloseKey; reg.OpenKey('Software\Classes\' + protocol + '\DefaultIcon', true); reg.WriteString('', ParamStr(0)); reg.CloseKey; reg.OpenKey('Software\Classes\' + protocol + '\shell\open\command', true); reg.WriteString('', '"' + ParamStr(0) + '" "%1"'); reg.CloseKey; reg.OpenKey('Software\Classes\' + protocol + '\shell', true); reg.WriteString('', 'open'); reg.CloseKey; reg.Free; end; Above function register a protocol and set its app association with the current program ( ParamStr(0) ). e.g. if you register with protocol 'myapp', then the URL will be like myapp://the-encoded-data-as-uri. Inside your app, call ParamStr(1) to get the parameters as URL form. Note: this solution is specific for Windows platform. Share this post Link to post
Die Holländer 45 Posted October 5, 2023 If you want to avoid the Browser Popup.. URLAllowlist.reg Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\URLAllowlist] "1"="myapp://*" [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge\URLAllowlist] "1"="myapp://*" [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Mozilla\Firefox\WebsiteFilter\Exceptions] "1"="myapp://*" Share this post Link to post
Alexander Halser 26 Posted October 5, 2023 (edited) On MacOS and iOS it's called CFBundleURLTypes. CFBundleURLTypes | Apple Developer Documentation Your app registers a url scheme in info.plist and once installed, you can address and open the app through the registered protocol, similar to Windows. Edited October 5, 2023 by Alexander Halser Share this post Link to post
Alexander Halser 26 Posted October 5, 2023 (edited) Registration of the url scheme will open your app, when such a link is being clicked (e.g. "myregisteredprotocol://this&is&url&data=whatever"). However, to receive and decode the url part, your application must implement the IURLEventHandler interface and add an event handler. Send me a PM if you need code for that. Edited October 5, 2023 by Alexander Halser Share this post Link to post
weabow 6 Posted October 6, 2023 Thank you Alexander. I will not hesitate one second... Share this post Link to post