c# – Xamarin:检查IOS设备中是否安装了任何特定的应用程序

我正在使用xamarin.forms,我可以使用Device类启动facebook应用程序,如下所示:

Device.OpenUri(new Uri("fb://profile/page_id"));

如果应用程序未安装在设备中,该怎么办?如何检查设备中是否未安装应用程序.

我在try块中编写了上面的代码行,但是当没有安装app时,代码仍会运行而没有任何输出和异常.我想重定向到itunes进行安装,如下所示:

CrossShare.Current.OpenBrowser("https://itunes.apple.com/us/app/facebook/id284882215/");

我在xamarin.forms中使用Plugin.share.

最佳答案 使用
AppLinks.你必须使用铆钉.

Linking to other apps – Instead of opening a web link in a browser
directly, you should let the App Links navigation take care of how to
open a link.

这是正确的方法.如果没有安装,它将处理存储导航,并根据您的URL处理浏览器.

你可以阅读更多关于它here.

Rivets.AppLinks.Navigator.Navigate("http://any.old.url");

Your app will now attempt to Navigate to another installed app for the
URL using App Links, or will fall back to usingUIApplication.OpenUrl in ios/or will fall back to using an intent with a view action in Android, if no App Link meta data is found, or no
apps for the metadata are installed.

点赞