【问题标题】:Launch Another IOS App from Xamarin Forms App从 Xamarin Forms App 启动另一个 IOS 应用程序
【发布时间】:2017-10-12 03:50:51
【问题描述】:

我正在尝试测试是否存在来自 MyApp (CanOpen) 的应用。如果是这样,我希望打开应用程序,否则我有一个 https 地址来打开 web 视图。我在开罐测试中得到了错误的回报。我相信我的代码是正确的,但我不确定 info.plist 是否存在。我有一个用于 MyApp 的 url 类型(在 info.plist 中)。我有另一个应用程序(健康)的 LSApplicationQueriesSchemes 条目,但不确定该引用如何与实际应用程序联系起来......非常感谢任何帮助:

MyApp PCL 中的界面如下:

   public interface IAppHandler
   {
       Task<bool> LaunchApp(string uri);
   }

在我对实际处理程序进行 deoendency 调用的模型视图中:

    string appid = @"health://";
    var result = await DependencyService.Get<IAppHandler>().LaunchApp(appid);

    if (!result)
    {
        Show_WebView(url);
    }

在平台特定的 AppHandler 中:

public Task<bool> LaunchApp(string uri)
{
    try
    {
        var canOpen = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(uri));
        if (!canOpen)
            return Task.FromResult(false);
        return Task.FromResult(UIApplication.SharedApplication.OpenUrl(new NSUrl(uri)));
    }
    catch (Exception ex)
    {
        return Task.FromResult(false);
    }
}

在 info.plist 中:

<key>CFBundleURLSchemes</key>
<array>
    <string>MyApp</string>
    <string>com.apple.Health</string>
</array>  
<key>LSApplicationQueriesSchemes</key>
 <array>
    <string>health</string>
 </array>

【问题讨论】:

  • 你需要注册你要打开的应用的URLScheme。
  • Shabir,使用捆绑 ID?谢谢
  • 我错过了如何将 LSApplicationQueriesSchemes 绑定到 URL 类型。
  • 没有bundle id不同,你需要注册另一个你要打开的应用的自定义URL方案
  • 检查我的答案

标签: ios xamarin


【解决方案1】:

您需要将目标应用的 URL Scheme 添加到 info.plist 文件中才能使用canOpen 功能。 IE

【讨论】:

  • roomreservation 是您在 OpenApp 语句中使用的名称吗?什么是 accom.ibm-cognos-mobile?
  • 两者都是 2 个不同应用的 URL 方案
  • 你在 uri 中传递了什么值?
  • 我尝试了一些不同的方法,但现在我正在使用健康
  • LSApplicationQueriesSchemesaccom.ibm.cognos-mobileroomreservation
猜你喜欢
  • 1970-01-01
  • 2017-02-22
  • 2021-01-20
  • 1970-01-01
  • 1970-01-01
  • 2020-12-15
  • 2019-11-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多