解決しました!(以下の「マジック ナンバー」は、ASObjc のバグによるものです)。
on applicationDidFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
-- Register the URL Handler stuff
tell current application's NSAppleEventManager's sharedAppleEventManager() to setEventHandler_andSelector_forEventClass_andEventID_(me, "handleGetURLEvent:", current application's kInternetEventClass, current application's kAEGetURL)
-- all your other application startup stuff..
end applicationDidFinishLaunching_
-- handler that runs when the URL is clicked
on handleGetURLEvent_(ev)
set urlString to (ev's paramDescriptorForKeyword_(7.57935405E+8)) as string
tell me to log "urlString: " & urlString
-- do stuff with 'Set AppleScript's text item delimiters to "foo="', and then "&" etc, to parse your parameters out of the URL String
end handleGetURLEvent_
また、info.plist は次の形式である必要があります。
<key>CFBundleIdentifier</key>
<string>com.myappname</string>
...
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>My App Name Helper</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myappscheme</string>
</array>
</dict>
</array>
これにより、アプリは次の形式の URL から入力を受け取ることができます。
myappscheme://com.myappname/?foo=stuff&bar=otherstuff
URL 全体が渡されて「urlString」変数に格納されるため、好きなように解析できます。つまり、必ずしも上記のような標準の URL 規則に従う必要はありませんが、そうすると便利な場合があるため、アプリで Facebook や Google マップの URL を簡単な構文で解析できる可能性があります。 http:// を myappscheme:// に変更
お楽しみください/お役に立てば幸いです.. :)