I have an app in the field which handles a url.  I mean, it has one of these in 
its Info.plist…

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>myapp</string>
            </array>
            <key>LSIsAppleDefaultForScheme</key>
            <true/>
        </dict>
    </array>

In order to fix a longstanding issue, I've now moved this entry, and the code 
to support it, into a helper app which is shipped in the main app's 
Contents/Helpers.  The idea is that the helper app now handles this URL instead 
of the main app.  I'm going to ship this as an update.  

It works for me, but due to past experience with the black-boxiness of Launch 
Services, I'm worried that users' experiences in the field will vary.  I'm not 
sandboxed.  So I've added some code which, upon first run of the updated app, 
spawns an NSTask to run lsregister, giving it the path to my app obtained from 
[[NSBundle mainBundle] bundlePath].  Since there are two paths to lsregister in 
Mac OS X history, I first try the new path, then if that does not return 0, the 
old path [1].  Running this command takes 80-100 milliseconds on my Core 2 Duo.

I'm worried there will still be trouble for some users, and would appreciate 
any feedback, design or test suggestions.

Thanks,

Jerry Krinock

[1] Here are the two commands I use:

Using new path to lsregister:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister
 -R /path/to/MyApp.app

Using old path to lsregister:

/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
 -R /path/to/MyApp.app

The arguments are passed in -[NSTask setArguments:], whose documentation 
indicates that I "do not need to do special quoting", which I interpret to mean 
that I need not quote the /path/to/MyApp.app.

The option "-R" means "Recursive directory scan, descending into packages and 
invisible directories", which I presume is necessary in order to find my helper 
buried in Contents/Helpers.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to