Xamarin.Forms(PCL)项目中的NotlmplementedException

Xamarin.Forms(PCL)项目中的NotlmplementedException

问题描述:

我在Xamarin.Forms(PCL)中编程,并且我看过很多帖子,但没有人为我工作。我使用该插件PhoneCall.Forms.Plugin 我做了一个包含下面的代码Xamarin.Forms(PCL)项目中的NotlmplementedException

try 
{ 
    var PhoneCallTask = CrossMessaging.Current.PhoneDialer; 
    if (PhoneCallTask.CanMakePhoneCall) 
    { 
     PhoneCallTask.MakePhoneCall("+528331607211", "Laura"); 
    } 
    else 
    { 
     DisplayAlert("Llamada", "No se puede hacer llamada", "Ok"); 
    } 
} 

它抛出一个错误一个按钮来调用一个方法:

System.NotlmplementedException: This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.

Deploy stops

+0

您必须将软件包与PCL项目一起安装到应用程序(iOS/Android)项目中。 – SushiHangover

+0

两个项目都安装了相同的软件包 –

+0

您可以添加一个链接到您正在使用的插件吗? – cvanbeek

您是否试过Messaging插件? 就像Jason here所说的那样。

尝试:

Device.OpenUri(new Uri("tel:528331607211"));

+0

在iOS上,Uri的格式为:telprompt:// 528331607211 – cvanbeek

+0

这不提供问题的答案。要批评或要求作者澄清,请在其帖子下方留言。 - [来自评论](/ review/low-quality-posts/17656686) – Dmitry

如果您正在使用this plugin(我不知道如果这是你正在使用或不特定的一个),那么你需要使用,使电话依赖服务(这在插件自述文件中有解释)。

制作的方法在你的PCL项目来调用服务扶养:

private void QCall(string number) 
{ 
    var notificator = DependencyService.Get<IPhoneCall>(); 
    notificator.MakeQuickCall (number); 
} 

在每个特定平台的项目,初始化插件。对于Android,这将在您的MainActivityOnCreate方法中完成,对于iOS中AppDelegateFinishedLaunching方法。以下行添加到每个Xamarin.Forms初始化后:

PhoneCallImplementation.Init(); 

然后当你在PCL项目称之为QCall()它将运行所必需的特定平台代码的用户是。