I have a custom url scheme working well, but there is one small behaviour I am hoping to change... Currently the inbound url is captured and processed in the following code (so, all good here):
- (void) handleURLEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent
{
NSString* url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
//I parse and deal with the url here//
}
Is it possible to avoid my app becoming the frontmost application? Whenever the url is received, my app is open already, as I initiated the communication from this app, and are merely listening for the reply. However, sometimes the call is made via an NSTimer so my app may or may not be the frontmost app. I don't want to disrupt the workflow if I am currently say browsing pages in Safari by having my app take the focus from Safari. I hope this makes sense.
Is this possible?
For anyone who's interested i instead set up a group container. I save my payload to the group defaults and then send an NSDistributedNotification from my helper app. The main app gets the notification, and reads the payload data from group defaults.
Such a workaround... but its necessary as both the main and helper apps are sandboxed.
I also discovered that KVO on group defaults doesn't work in the sandbox, and neither does sending a userDictionary in the NSDistributedNOtification. :(
I have had to write sooo much extra code to make my app play nicely in the sandbox.