3

Possible Duplicate:
Programmatically open Mac App Store

I'm developing a 10.8.0+ OSX App and I need to programmatically show the App Store for the user to update his OS in order to use the Facebook Integration (only if he's not on 10.8.2).
How can I open the App Store to the Updates section, or something similar that does the same thing?

Community
  • 1
  • 1
Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76
  • Do you just want to open the app store to the app's page to update it? Or to the actual updates section? – PRNDL Development Studios Oct 22 '12 at 18:45
  • 5
    I'm skeptical that a third party application should do something like this. The OS already has built-in settings for checking for updates and notification. – bames53 Oct 22 '12 at 18:52
  • If this were possible, it would probably be exposed through AppleScript. Unfortunately, the scripting dictionary for `App Store` only contains boilerplate. At best, you can fire up the app itself. – millimoose Oct 22 '12 at 18:57
  • If the user is on 10.8.0 he cant use NSSharingService Facebook, so i tell the user to update his OS. That's why i need to send the user to the App Store App on the updates Section. – Pedro Vieira Oct 22 '12 at 19:00
  • 1
    @PedroVieira I wouldn't bet on someone paying $30 for an OS X upgrade just to share stuff to Facebook - it is my impression that the OS X user base is basically composed of people who upgrade as a rule, or people who only upgrade by replacing hardware with the new OS preinstalled. If you think the installed base of 10.8 is too low, you should make that feature optional. (Sharing to FB is hardly vital.) – millimoose Oct 22 '12 at 19:01
  • @millimoose have u read the question? it's an App for 10.8+. But only on 10.8.2 (sry if mistaken) OSX came with Facebook integration. – Pedro Vieira Oct 22 '12 at 19:03
  • @PedroVieira I read your *question*, which says none of that! Maybe if you edited a clear description of your use case instead of implying it across several comments it would. – millimoose Oct 22 '12 at 19:07
  • In case you read my answer earlier before my EDIT, see my additions that gives the URL to open the Mac AppStore to the Updates tab directly – AliSoftware Oct 22 '12 at 20:16

1 Answers1

4

Using iTunes Link Maker you can get a link to open the Mac AppStore on the MacOS X 10.8 page (simply search for "OSX" in the "Mac Applications" section) like this one:

https://itunes.apple.com/us/app/os-x-mountain-lion/id537386512?mt=12&uo=4

Using this link directly will unfortunately open your browser that will request the user to click on a button to open the page in the Mac AppStore, but after digging quickly in the javascript code associated with this button, it is easy to see than replacing "https://" with "macappstores://" will open the Mac AppStore directly without opening your default web browser before.

So in short, making your application open the link below should do the trick:

NSString* const kOSX8AppStoreURL = @"macappstores://itunes.apple.com/us/app/os-x-mountain-lion/id537386512?mt=12";
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:kOSX8AppStoreURL]];

Of course this does open the page of the "OS X Mountain Lion" application in the AppStore, and not really the "Updates" tab of the Mac AppStore application, but I think it is the best you can do.


EDIT : Open the "Updates“ tab of the Mac AppStore!

After digging into the requests sent by the Mac AppStore application to check the updates (thanks to a Man-In-The-Middle proxy and a trusted CA certificate to lure AppStore.app HTTPS requests, and some Base64 decoding), I finally found the URL to open the "Updates" page of the Mac App Store!

So this is the URL I discover that open the Updates tab directly :

https://su.itunes.apple.com/WebObjects/MZSoftwareUpdate.woa/wa/viewSoftwareUpdate

I tested it so far and it opens the AppStore.app if not open already, goes to the Updates tab, and start searching for new updates right away :)

AliSoftware
  • 32,623
  • 6
  • 82
  • 77
  • i tried using `[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"macappstores://su.itunes.apple.com/WebObjects/MZSoftwareUpdate.woa/wa/viewSoftwareUpdate"]];` but it doesn't work, occurs an error on the AppStore App. – Pedro Vieira Oct 22 '12 at 20:46
  • And what about my first link ? And what abou if you try using the `open` command in the terminal to open the URL? – AliSoftware Oct 22 '12 at 21:02
  • 2
    Looks like "macappstore://showUpdatesPage" URL will work also. – Dave Ross Mar 25 '13 at 22:05