简体   繁体   中英

Programmatically open Mac App Store

I am trying to programmatically open the Mac App Store in a custom Mac App. I started with the link below.

http://itunes.apple.com/us/app/angry-birds/id403961173?mt=12

I tried the following code, however it opens the browser rather than the Mac App Store.

[[NSWorkspace sharedWorkspace] openURL:
 [NSURL URLWithString:@"http://itunes.apple.com/us/app/angry-birds/id403961173?mt=12"]];

Any suggestions on how I can do this?

URLs of this pattern open up the Mac App Store:

macappstore://itunes.apple.com/app/id403961173?mt=12

So in your case:

[[NSWorkspace sharedWorkspace] openURL:
 [NSURL URLWithString:@"macappstore://itunes.apple.com/app/id403961173?mt=12"]];

will open the MAS and load the product page associated with id #403961173 (here: Angry Birds).

To just load the MAS, with no particular product page use this URL:

[[NSWorkspace sharedWorkspace] openURL:
 [NSURL URLWithString:@"macappstore://itunes.apple.com/"]];

如果您只想显示更新页面,可以使用以下URL:macappstore:// showUpdatesPage

open the webpage in a UIWebView. the webview will then open itunes, or at least ask to open itunes.

that may be iphone specific. but whatever the WebView is for mac.

怎么样:

[[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/App Store.app"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM