feedback:// how can this be implemented

Greetings,

I guess this is not new , but there is a way I can find some documentations about this ? I want to have same for our app on our website and when you press on it to open the app for example and do some things so I will need to know how do I doit on the website and how do I handle that in the OS as well on the app.

Does it work on Windows and Mac , or only on Mac , does it work on IOS ?

Thanks in advance.

The new version of feedback will be a web application so this may be the better route for you to go with an online database, and the correct URL sent from your software all targets could access a web application to update/serve feedback requests.

These things are called URLHandlers. I have an IDE script to add those to my app (Mac only):

[code]'add url schemes

dim dbg as String
if debugBuild then dbg = “.debug”
dim appNameForShell as string = PropertyValue(“App.MacOSXAppName”) + dbg +".app" + “/Contents/Info.plist”
appNameForShell = replaceall(appNameForShell, " ", "\ ")

dim BundleID as String = PropertyValue(“App.Application Identifier”)
if BundleID = “” then
print “Bundle ID for url scheme missing”
Return
end if

dim theResult as String
theResult = DoShellCommand("/usr/libexec/PlistBuddy -c ““add :CFBundleURLTypes array”” " + CurrentBuildLocation + “/” + appNameForShell)

‘scheme for clicking links
dim SchemeName as String = ConstantValue(“MimeURLHandler.SchemeName”)
call DoShellCommand("/usr/libexec/PlistBuddy -c ““add :CFBundleURLTypes:0 dict”” " + CurrentBuildLocation + “/” + appNameForShell)
call DoShellCommand("/usr/libexec/PlistBuddy -c "“add :CFBundleURLTypes:0:CFBundleURLName string '” + BundleID + “.” + SchemeName + "’"" " + CurrentBuildLocation + “/” + appNameForShell)
call DoShellCommand("/usr/libexec/PlistBuddy -c ““add :CFBundleURLTypes:0:CFBundleURLSchemes array”” " + CurrentBuildLocation + “/” + appNameForShell)
call DoShellCommand("/usr/libexec/PlistBuddy -c ““add :CFBundleURLTypes:0:CFBundleURLSchemes:0 string '” + SchemeName + “’”” " + CurrentBuildLocation + “/” + appNameForShell)[/code]

Well it was not about feedback it was more about the App url itself, I will have it like myapp:// but I wanted to know how it will be implemented in Windows / Mac on the OS level so when you press on that web URL it will start automatically my app and handle the parameters.

[quote=467575:@Beatrix Willius]These things are called URLHandlers. I have an IDE script to add those to my app (Mac only):

[code]'add url schemes

dim dbg as String
if debugBuild then dbg = “.debug”
dim appNameForShell as string = PropertyValue(“App.MacOSXAppName”) + dbg +".app" + “/Contents/Info.plist”
appNameForShell = replaceall(appNameForShell, " ", "\ ")

dim BundleID as String = PropertyValue(“App.Application Identifier”)
if BundleID = “” then
print “Bundle ID for url scheme missing”
Return
end if

dim theResult as String
theResult = DoShellCommand("/usr/libexec/PlistBuddy -c ““add :CFBundleURLTypes array”” " + CurrentBuildLocation + “/” + appNameForShell)

‘scheme for clicking links
dim SchemeName as String = ConstantValue(“MimeURLHandler.SchemeName”)
call DoShellCommand("/usr/libexec/PlistBuddy -c ““add :CFBundleURLTypes:0 dict”” " + CurrentBuildLocation + “/” + appNameForShell)
call DoShellCommand("/usr/libexec/PlistBuddy -c "“add :CFBundleURLTypes:0:CFBundleURLName string '” + BundleID + “.” + SchemeName + "’"" " + CurrentBuildLocation + “/” + appNameForShell)
call DoShellCommand("/usr/libexec/PlistBuddy -c ““add :CFBundleURLTypes:0:CFBundleURLSchemes array”” " + CurrentBuildLocation + “/” + appNameForShell)
call DoShellCommand("/usr/libexec/PlistBuddy -c ““add :CFBundleURLTypes:0:CFBundleURLSchemes:0 string '” + SchemeName + “’”” " + CurrentBuildLocation + “/” + appNameForShell)[/code][/quote]
Thanks,

I assume that this is for the Mac side, is it doable for windows apps as well ? as I saw something here I guess some details about it but I will have to dig into it .

thanks again.

So apparently managing AppURIHandlers on Windows all the details are here , I’ll have to check as well how you do on Mac and then how you doit on the web side on a html site or php side as well , not only wojo web app.

Windows is tricky, because it will launch a second copy of your application with the url as the first parameter. So your goal would be to take that url and pass it to your already-running version, if there is a version already running.

My Beacon Xojo app does this for both Mac and Windows, though it’s much easier on Windows. I don’t have a true tutorial available, but I can point you to some things to look at in the app’s code.

For Mac, as @Beatrix Willius mentioned, you need to update the Info.plist. In the Beacon project, there is an “UpdateInfoPlist” build step that injects the url handler. There are a couple commands there, but you only need the one that adds CFBundleURLTypes. Next, you’ll have App.HandleAppleEvent which just takes the passed url and hands it off to HandleURL which is where the cross-platform handling happens. Do what you want from there. So for Mac, this is pretty simple.

For Windows, start with the InnoSetup script in Installers/Windows/Setup.iss and the commands are down around line 104 at the time of this writing. You need to have your installer setup stuff in the registry to do it. Then back in the Xojo project, in App.Open I try to obtain a Mutex very early. If I cannot, that means an instance of the app is already running, so on Windows, I take the command line parameters and attempt to pass them to the other instance using an IPCSocket. If I can obtain the mutex, I open an IPCSocket and listen for the incoming parameters. This is the mHandoffSocket property with the event handlers mHandoffSocket_DataAvailable and mHandoffSocket_Error. The DataAvailable handler basically looks ahead of the buffer, and reads up until the Null character if the command is complete. When it is, passes off to HandleCommandLineData, which determines if it was a URL, and if so, hands it over to HandleURL again.

There’s a lot of work involved for Windows, which means plenty to get wrong. Sorry I don’t have a real tutorial, but what you’re looking to do is definitely possible.

https://blog.xojo.com/2016/05/09/let-your-os-x-desktop-app-react-to-custom-uris/
https://blog.xojo.com/2016/08/16/custom-uri-schemes-on-windows/

2 Likes

[quote=467613:@]Let Your OS X Desktop App React to Custom URIs – Xojo Programming Blog
https://blog.xojo.com/2016/08/16/custom-uri-schemes-on-windows/[/quote]
cool, thanks

Trying to test this part, it seems that on MacOS is ok, but on Windows, it always launches the app each time the CustomURL is called, is there a way in case the app is opened to just pass the parameter and not to launch another instance of the app again ?

Any ideas on that ?

For the Registry part I put a code in the App.Open in order to check registry to see if the key is there or not and if not to create one, but it seems as well that I need the app to always run in Administrator mode in order to allow access to Registry, that could be a easy fix on editing the App properties but is there another way ? or Registry is only for Admins ? as access ?

Thanks.

You need to use some sort of mechanism to send the instruction to the already-running instance. A mutex and ipc socket combination is a common technique.

When your app launches, it attempts to obtain a lock on a mutex. If it works, it starts a listening ipc socket. If it does not, it connects to that ipc socket, sends the command line data, and terminates.

well the app is called from a browser URL so as far as I know to initiate an IPC socket you need both apps to know how to do that. For the 1 instance the mutex did the job , the parameter part is little bit confusing I guess. On MacOS we have the HandleAppleEvent that does the magic but nothing on windows so far .

I did found on the MSDN that apparently you need to Register the URL and then to properly handle it in the app, but I’m not sure we can have that on XOJO. Here are the details https://docs.microsoft.com/en-us/windows/uwp/launch-resume/handle-uri-activation . I gues it would be nice to have similar functionality on Windows as well, that will open new horizons .

Thanks.

It’s all possible. See my previous reply to you. feedback:// how can this be implemented

Would be great if Xojo could create some counterpart “Application.HandleWinEvent” and functions to make simple use of it too. https://docs.microsoft.com/en-us/windows/win32/winauto/winevents-infrastructure

2 Likes

If you use App Wrapper, you can declare the URL you want to handle in the AW GUI.

You’re still required to handle the GURL Apple Event.

So, you mean that the GURL Apple Event works on MacOS and on Windows as well ? I guess then It has the wrong name :stuck_out_tongue_winking_eye: for now I already handle that for the Mac side so if works on windows then I guess the issue would be only on registering the link and if you said that App Wrapper could do the job then I’ll have a look on it.

Thanks.