Xamarin Macintosh客户URL协议句柄传递的参数 [英] Xamarin Macintosh Customer URL protocol handle passed parameter

查看:77
本文介绍了Xamarin Macintosh客户URL协议句柄传递的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了处理自定义协议的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:

在Objective-C中访问命令行参数

看起来像这样:

string[] args = NSProcessInfo.ProcessInfo.Arguments;

这篇关于Xamarin Macintosh客户URL协议句柄传递的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆