Recognizing a second App start

Hi,


Is there a possibility to get informed (by for example signal/hook/handler), that the current running App has been started a second time?


My use case is an App, that is minimized into the status bar, but does show a window when the user starts the app a second time. To do this I have to be able to detect the second start. Is there an API for solving this? I could not find one.


While trying some stuff I found some strange behaviour of macOS. When I install my App fresh from the dmg and start the App two consecutive times (from Finder or using open), then my main method gets executed on both runs. I can then start the App multiple times, every time my main method runs. But when the App doesn't get started for some time (ca. 15 minutes), a launch of the App does not execute my code anymore. Nothing changes this state, neither restart of the App, reinstall from the same dmg or rebooting the Mac. Only when I create a new dmg and reinstall I the App from it I can again run my code a second time.

Recognizing a second App start
 
 
Q