Re: Re: Open my Application via safari
Re: Re: Open my Application via safari
- Subject: Re: Re: Open my Application via safari
- From: "Shawn Erickson" <email@hidden>
- Date: Thu, 2 Nov 2006 09:57:59 -0800
On 11/2/06, Yorh <email@hidden> wrote:
Hi to all,
Does anyone is able to send me a very basic example (an empty
project), with this function?
I will try on my mac ...
The following works for me... all I need to do after building the
application is run it once by double clicking it (developer only issue
since user copying it onto their systems should trigger automatic
registration). Then I can type Foo://blah/blah/blah and my application
gets launched and can display the URL.
(working on an example project that I can provide to the public...)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array/>
<key>CFBundleExecutable</key>
<string>Foo</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundleIdentifier</key>
<string>com.bar.foo</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLIconFile</key>
<string>URLIcon</string>
<key>CFBundleURLName</key>
<string>Foo URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>Foo</string>
</array>
</dict>
</array>
</dict>
</plist>
Then in my app delgate...
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
NSAppleEventManager *appleEventManager = [NSAppleEventManager
sharedAppleEventManager];
// Get URL Apple Event ('GURL') is part of the internet AE suite not
the standard AE suite and
// it isn't currently supported directly via a application delegate
method so we have to register
// an AE event handler for it.
[appleEventManager setEventHandler:self
andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:'GURL'
andEventID:'GURL'];
}
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSLog(@"GURL = %@", event);
NSAppleEventDescriptor* urlDescriptor = [event
descriptorForKeyword:keyDirectObject];
[self doSomethingWithURL:[NSURL URLWithString:[urlDescriptor stringValue]]];
}
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden