Xamarin Macintosh 客户 URL 协议处理传递的参数 [英] Xamarin Macintosh Customer URL protocol handle passed parameter
问题描述
我编写了一个处理自定义协议的 Macintosh 应用程序:
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
coolhandler://Iwant/toparse/this
在 Windows 中,注册表项很简单,而且工作正常.当我的 Windows 应用程序启动时,整个 url 作为参数传递,我可以解析它.
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
}
在我的 pList 或应用程序中,我应该在哪里处理这个问题?即,如何将 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?
推荐答案
你可能需要在 C# 中做这样的事情:
You'll need to do something like this in C# likely:
看起来像:
string[] args = NSProcessInfo.ProcessInfo.Arguments;
这篇关于Xamarin Macintosh 客户 URL 协议处理传递的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!