Xamarin Forms上的Facebook URL方案

时间:2015-07-31 12:32:57

标签: facebook xamarin xamarin.forms

几周前,我在Xamarin论坛上提出了一个问题,即我使用Xamarin Forms的Facebook Schemes问题,更确切地说是iOS问题。 (这里的问题是:https://forums.xamarin.com/discussion/comment/141207/#Comment_141207)。我仍然没有回答,所以我决定向StackOverflow提出要求,以增加我得到答案的机会。

我尝试在Facebook应用程序上打开一个URL(如果已安装),如果没有打开Web浏览器。 我有那个代码:

try{
    Device.OpenUri (new Uri("fb://page/page_id"));
}
catch(Exception e){
    System.Diagnostics.Debug.WriteLine (e.Message);
    Device.OpenUri (new Uri("https://www.facebook.com/pages/...."));
}

它在Android上完美运行,如果未安装Facebook或者方案不正确,则会引发ActivityNotFoundException。

但是在iOS上没有任何异常。我还没有尝试过Windows Phone。 有谁知道iOS平台为什么不引发异常?

提前致谢。

1 个答案:

答案 0 :(得分:0)

Have you tried this on a real device? This URI is probably not supported on an emulator. If you look at how iOS opens URI it usually just returns false instead of an exception if it can't open an URI which is probably why you don't see an exception. You should see the same thing if you try and make a phone call from the emulator.