I have one Cocoa application and one launch agent. Launch agent launches application using
launchAppWithBundleIdentifier:
method call.
Inside my application I want to check application is launched by user(Normal launch) or is it launch agent launching my application.
Asked
Active
Viewed 676 times
3

Raviprakash
- 2,410
- 6
- 34
- 56
1 Answers
2
It seems like you should be able to send an Apple Event via the additionalEventParamDescriptor: parameter of the launchAppWithBundleIdentifier: call and then receive that in your app so you know it's your agent launching you.

Ken Aspeslagh
- 11,484
- 2
- 36
- 42
-
2Thanks. I found the way to recieve. In my App delegate i wrote following method: `-(BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { NSAppleEventDescriptor *event = [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent]; if (event) { AEEventID evtID = [event eventID]; if (event && ( evtID == kAEOpenApplication) && [event eventClass] == kCoreEventClass) { //Here some code } } return YES; }` – Raviprakash May 10 '11 at 09:52
-
Great. I wasn't sure you how you would receive it but it sounds like you figured it out! – Ken Aspeslagh May 15 '11 at 23:25
-
I asked a question about this strategy here: https://stackoverflow.com/questions/57438168/how-to-send-and-receive-nsappleeventdescriptor-when-using-nsworkspace-to-open-ur – pkamb Aug 20 '19 at 00:03