What is the best way to 'react' to LSHandlers?


I would like my OSX app be able to handle if the user 'opens' a particular kind of file with Finder.  I was able to get OSX to start up my app using some LaunchServices hackery, so far so good.

But the JUCE application gets both an 'initialise' and a 'anotherInstanceStarted' call in such a case, and it seems the 'anotherInstanceStarted' actually had the filename of the 'opened' file.  Seemingly also good.

However, I also see that if I start my binary directly (e.g. full path to the binary, not opening the .app) then both calls occur as well.

What is the correct startup sequence, and how should I properly handle all these scenarios in the JUCE framework?

  • run binary without any parameters
  • run binary with parameters (e.g. a file to open, or whatever)
  • launch binary via LSHandler due to 'open' of an associated file type

I need to handle all these using the same binary, so it would be great if you could clarify the expected sequence of Application startup calls in each scenario.