launch another app from within cocoa
I am working on a project that that needs to send an html link to another app. What I need is exactly what happens when you click an email link in a browser, it sends the link to mail. Or an itunes store link opens itunes. I have the link I just need to send it to another app. Specifically, veoh web player, which already opens when a veoh download link is clicked in my browser. I could probably round up the answer if I knew what to search for.
Thank you,
Todd
Todd
The URL:
mailto:fred@flinstone.com?subject=hello%20wilma&body=how%20is%20barny%20today
starts up the default mail application (which you can set from Preferences in Mail.app)
You can fire it up from terminal with the open command:
$ open "mailto:...................today"
I wrote a little tutorial about building your own browser with web kit. Code: http://clanmills.com/files/BYOB.zip Tutorial: http://clanmills.com/files/BYOB.pdf. If you run that code and enter 'mailto:fred......today' and press 'Go', webkit will do the rest. If you want to 'hide' this from the user, I expect that an invisible webview window will 'do the business' with code like this:
// display the address in the webview
[[webView mainFrame] loadRequest:
[NSURLRequest requestWithURL:[NSURL URLWithString: address ]
]];
The URL specification provides a 'scheme' and address. Common schemes are http: ftp: mailto: file: I wasn't aware that itunes has its own scheme. For sure the terminal command:
$ open http://clanmills.com
will launch the default browser on my web site. You can call commands from Cocoa with the 'system()' API. I believe the class NSTask provides a cocoa 'wrapper' for executing other processes from Cocoa.
Apps (such as Safari.app and Firefox.app) have a command-line program buried inside their bundle (in the Contents/MacOS directory) and you can usually start up applications from the terminal (or system()) API and pass arguments.
I don't know anything about iTunes, however I found the following:
http://www.macosxhints.com/article.php?story=20011108211802830
I also found this on apple.com http://developer.apple.com/safari/library/featuredarticles/iPhoneURLScheme_Reference/Articles/iTunesLinks.html
When I entered the URL mentioned on that page:
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=156093464&id=156093462&s=143441
Chrome (my default browser) launched iTunes and I was rewarded with Randy Newman singing "you've got a friend in me".I hope that helps.Thanks for pointing me in the right direction. I also found this: Launching Other Apps from within an iPhone App. I am not developing for iPhone, yet, but I think the principles are abasically the same.
Todd