Hi Ken,
On 31 Jan 2009, at 02:13, Ken Thomases wrote:
On Jan 30, 2009, at 10:58 AM, Dave wrote:
In order to register an Application to handle a protocol, do I
have to change anything other than add URL Types in the Plist
file? I'm having problems with my application not being opened
when a protocol request is sent with a protocol ID that my App is
registered for, e.g. it's Plist file says it should handle it.
By "protocol" I'm assuming you mean a URL scheme, right? Perhaps
you can show the XML for that part of your Info.plist.
Yes, a URL scheme, here is the XML for the whole plist file after I
added the URLTypes:
www.apple.com/DTDs/PropertyList-1.0.dtd">
CFBundleURLTypes
CFBundleURLName
Internal Protocol GdSC
CFBundleURLSchemes
GdSC
CFBundleDevelopmentRegion
English
CFBundleDocumentTypes
CFBundleTypeExtensions
CFBundleTypeIconFile
ShowcaseDoc.icns
CFBundleTypeName
Showcase Dev Files
CFBundleTypeOSTypes
CFBundleTypeRole
Editor
CFBundleExecutable
Showcase Dev
CFBundleIdentifier
com.genx.showcase
CFBundleGetInfoString
Get Info Version 1.0.0.0198
CFBundleIconFile
Showcase.icns
CFBundleInfoDictionaryVersion
6.0
CFBundleLongVersionString
Version 1.0.0.0198
CFBundleName
Showcase Dev
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0.0.0198
CFBundleSignature
GdSC
CFBundleVersion
2.8.1.472
CSResourcesFileMapped
LFPrefersCarbon
LSGetAppDiedEvents
NSAppleScriptEnabled
YES
NSHumanReadableCopyright
Copyright 2008 - All Rights Reverved.
Do have to change anything else?
Well, Launch Services should launch your app without you having to
do anything else, but your app won't do anything unless you
register a handler for the 'GURL' (get URL) Apple Event.
Launch services doesn't seem to get called, or at least it doesn't
load the app. The application already handling GURLs ok, so the
handler should be called. My code is in a plugin and I can get it to
work when I map it manually using the "More Internet" System Prefs
Panel. There are a number of plug-in type app that get passed the URL
from a sort of Framework the way I have set it up is that I use the
CreatorCode of the as the Protocol (I think I will change it so it's
always prefixed with a constant, e.g.GdSc, GxSC, GxTT
etc. (these get mapped to all lowercase)). But for now I think I have
got it working ok, I'm not sure if it was the "More Internet" panel
or if I needed to copy the application as you suggested, but when I
tried it with a different "Prootcol" code, e.g. "GxXX" it worked ok.
http://developer.apple.com/documentation/Cocoa/Conceptual/
ScriptableCocoaApplications/SApps_handle_AEs/chapter_11_section_4.html
Do I have to do something special at install or run time?
No. During development it's sometimes the case that the Finder or
Launch Services doesn't realize that your app's capabilities have
changed. The new Info.plist isn't rescanned to update the system
caches. If you duplicate your app in the Finder, does the new copy
get opened for the URL scheme?
Lastly, are you sure there isn't some other application that claims
the same scheme? If there is, it's up to the system to decide
which to use for a given scheme, unless the user has specified a
preference.
There is no central system-provided GUI for the user to specify
their preference for handlers for URL schemes. Safari's
preferences let you specify the preferred handler for http: and
Mail's for mailto:. You can implement a similar interface using
LSSetDefaultHandlerForURLScheme, but you should only do so in
response to the user expressing their preference. It's bad form to
"steal" that preference from the user.
These are just private protocol keys between our server and the
application. We have picked some obscure names for the "protocol"
handlers we are using, but I'm not sure how to prevent a conflict
with other applications. I have used the Creator Code of the
application as a key, I could use the Creator ID with the dots
deleted instead, e.g. comshowcasegenx. What do you think? At the
moment I have chosen 4 character constant followed by the
Application's Creator Code.
Thanks for you hel