Xamarin Macintosh Customer URL protocol handle passed parameter

こ雲淡風輕ζ 提交于 2020-01-02 09:53:58

问题


I've written a Macintosh app that handles a custom protocol:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>My Cool Handler</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>coolhandler</string>
        </array>
    </dict>
</array>

All well and good. It launches. However, I'm clicking on a link like this:

coolhandler://Iwant/toparse/this

In Windows, the registry entry is simple and this work just fine. When my Windows app launches, the whole url is passed as an argument and I can parse it.

    protected override void OnStartup(StartupEventArgs e)
    {
        _url = !e.Args.Any()?"":e.Args[0];
        //parse the url
    }

Where, in my pList or in the app do I handle this? i.e, how do I pass the url argument to the app?


回答1:


You'll need to do something like this in C# likely:

Accessing command line arguments in Objective-C

Which would look something like:

string[] args = NSProcessInfo.ProcessInfo.Arguments;


来源:https://stackoverflow.com/questions/42787480/xamarin-macintosh-customer-url-protocol-handle-passed-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!