Search code examples
c#windows-phone

Make a phone call In Windows 10 mobile


I writing app for Windows 10 Mobile

I need to call Phone Task, when I tap a button.

I try to do it like this

 private void TelephoneButton_Click(object sender, RoutedEventArgs e)
    {
        var phoneCallTask = new PhoneCallTask
        {
            PhoneNumber = "+380442308888",
            DisplayName = "The Name goes here"
        };

        phoneCallTask.Show();

    }

and using this using Microsoft.Phone.Tasks;

But I have this error in using Error CS0234 The type or namespace name 'Phone' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

and this in PhoneCallTask

Error   CS0246  The type or namespace name 'PhoneCallTask' could not be found (are you missing a using directive or an assembly reference?)

What's wrong and how I can call Phone Task?


Solution

  • You need to use PhoneCallManager. A reference is needed to Windows.Foundation.UniversalApiContract.

    Then you could do something like this:

    private void TelephoneButton_Click(object sender, RoutedEventArgs e)
    {
        Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI("+380442308888", "The Name goes here");
    }
    

    Update add a reference enter image description here