Vidux
Vidux

Reputation: 303

Bring other running app's window to front

What I am trying to achieve: when user presses "buy" in my app, App Store window should appear with my app url in it.

This works fine when App Store is not running: [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"macappstore://..."]];

But when App Store is already running and is minimised in the dock it's window doesn't show up. It becomes active, yes, but the window doesn't appear.

What I have already tried: fetched app using NSRunningApplication and trying to unhide, activateWithOptions: it, but this doesn't work.

I don't see more options in NSWorkspace and NSRunningApplication, so if someone have some solutions for this, it would be appreciated.

Upvotes: 0

Views: 512

Answers (2)

Loengard
Loengard

Reputation: 431

But doesn't this bring it to the front even if it's minimized?

NSWorkspace.shared.launchApplication("App Store")

Upvotes: 1

seth
seth

Reputation: 1708

Mmm I can't think of any approach that does not involve Applescript or Accessibility APIs which then requires the user give your app access permission which is even worse. (I mean, you could quit and relaunch App Store, but that's jarring.) Honestly this is bad behavior in App Store, so you should file a report with Apple noting the window doesn't come to the front. It won't help you now, though.

Upvotes: 1

Related Questions