I made a package to deploy a PB application on MacOS. I use the Info.plist to assign the application as editor/viewer for the extension rgf. If I now double click such a file in MacOS, my application is launched. Sadly, the clicked file is not provided as commandline parameter. My application does not know about such a file.
Unfortunately CocoaMessage isn't always the solution and the problem is complicated.
I'll try to explain ...
Normally every application can have a delegate that handles several issues.
Opening documents is one of them. NSApplicationDelegate has a method named application:openFile: for this purpose.
The problem is that an application can only have one application delegate and PureBasic itself already sets one so changing the delegate will cause problems.
Another way would be to use the NSAppleEventManager class to set your own manager for the event that is triggered when a document has to be opened.
This should be possible but would require quite a lot of code.
Third possible way is to use method swizzling meaning you get the implementation of the method application:openFile: (a pointer to a C function) and exchange that with your own function.
From the three options this is the easiest one but as far as I understand Apple isn't happy with this and you risk an app being rejected from the AppStore if you do it this way.
What you could do with CocoaMessage is get the arguments passed to the application but you mention a filename isn't passed as an argument so in that case this wouldn't help.
So there is no quick solution if PB itself has no support for this.