NotlmplementedException in Xamarin.Forms (PCL) project

200 Views Asked by At

I'm programming in Xamarin.Forms (PCL), and I have seen many post but none one works for me. I'm using the plugin PhoneCall.Forms.Plugin I made a method to call with a button that contains the next code

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

It throws an error:

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

3

There are 3 best solutions below

0
JorgeMadson On

Have you tried the Messaging plugin? Like said by Jason here.

1
Rendy Del Rosario On

Try:

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

0
cvanbeek On

If you are using this plugin (I'm not sure if this is the specific one you're using or not), then you need to make the phone call using a Dependency service (This is explained in the plugin readme).

Make a method in your PCL project to call the dependancy service:

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

In each platform specific project, initialize the plugin. For Android, this will be done in the OnCreate method of your MainActivity, and for iOS in AppDelegate in the FinishedLaunching method. Add the following line to each after the initialization of Xamarin.Forms:

PhoneCallImplementation.Init();

Then when you call QCall() in your PCL project it will run the code necessary for the specific platform the user is on.