0

我在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

回答

0

嘗試:

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

+0

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

+0

這不提供問題的答案。要批評或要求作者澄清,請在其帖子下方留言。 - [來自評論](/ review/low-quality-posts/17656686) – Dmitry

0

如果您正在使用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()它將運行所必需的特定平臺代碼的用戶是。

相關問題