【问题标题】:How to use URL schemes to open another Application from my Application in Xamarin iOS如何在 Xamarin iOS 中使用 URL 方案从我的应用程序打开另一个应用程序
【发布时间】:2016-05-18 19:08:26
【问题描述】:

我想要的是,在 iOS 中从我的 Xamarin Forms 应用程序打开另一个应用程序。我阅读了 iOS 中的 URL 方案,但是如何在 Xamarin 应用程序中实现它。我正在使用依赖服务来调用本机函数。我已经在 Android 中做到了,并且运行良好。

我找到了一个链接 https://riccardo-moschetti.org/2014/10/03/opening-a-mobile-app-from-a-link-the-xamarin-way-url-schemas/。但它使用 Xamarin Studio,我使用的是 Visual Studio,而 VS2015 没有这个选项。

有人对此有更好的解决方案吗?

【问题讨论】:

  • 你可以在两个 IDE 中获取 info.plist 的 xml 版本。复制粘贴,应该可以解决你的问题
  • 但是我必须将解决方案复制到 MAC,因为 Xamarin 不支持 Windows 上的 iOS 开发。
  • 它确实支持,你只需要有一个mac来构建!
  • 它没有兄弟。看看它。 Xamarin 不支持在 Windows 上进行 iOS 开发
  • 我的意思是,你可以使用 Visual Studio 社区!

标签: xamarin xamarin.ios xamarin.forms


【解决方案1】:

我已经通过在我要打开的应用程序的 info.plist 中添加以下键来解决它。

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>com.example.ios</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>testscheme</string>
        </array>
    </dict>
</array>

然后使用下面的代码打开应用程序

if(!UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("testscheme://com.example.ios")))
{
//Use the code below to go to itunes if application not found.
UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("itms://itunes.apple.com/in/app/appname/appid")); 
}

【讨论】:

  • 我正在以类似的方式处理 url。但是当我的应用程序已经打开时,从链接打开应用程序会停止应用程序并重新启动。正常吗?你知道如何在不杀死应用程序的情况下打开链接吗?
猜你喜欢
  • 2017-05-24
  • 1970-01-01
  • 2020-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-26
  • 2016-11-22
  • 1970-01-01
相关资源
最近更新 更多