简体   繁体   中英

NotlmplementedException in Xamarin.Forms (PCL) project

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.

部署停止

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

尝试:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM