Eng Soon Cheah
Eng Soon Cheah

Reputation: 257

phone call in Windows 10 UWP

Currently, I found Windows.ApplicationModel.Calls API. unable to make a call or launch different options available to make a call from my app. And also I try this Code but still can't implement the Phone call function, any solutions for UWP? Thank You.

if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.Calls.CallsPhoneContract", 1,0))
{
    PhoneCallManager.ShowPhoneCallUI("0213132131", "my name");
}

Upvotes: 3

Views: 4869

Answers (2)

miskohut
miskohut

Reputation: 1017

I've come with a solution that is working on emulator, I cannot test it on actual device, cause I don't own one.

PhoneCallStore PhoneCallStore = await PhoneCallManager.RequestStoreAsync();
Guid LineGuid = await PhoneCallStore.GetDefaultLineAsync();

PhoneLine = await PhoneLine.FromIdAsync(LineGuid);
PhoneLine.Dial(phoneNumber, nameToBeDisplayed);

You have to add Windows Mobile Extentions for UWP to references of your project as well as declare PhoneCall capability in app manifest.

Upvotes: 5

Raamakrishnan A.
Raamakrishnan A.

Reputation: 535

The line,

PhoneCallManager.ShowPhoneCallUI("0213132131", "my name");

only shows the Call UI. It doesn't make a phone call.

You should use Windows.ApplicationModel.Calls.PhoneLine.Dial to make a phone call. See this for reference https://msdn.microsoft.com/en-us/library/windows.applicationmodel.calls.phoneline.aspx

See this example https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/PhoneCall/cs/Helpers/CallingInfo.cs#L85

Upvotes: 3

Related Questions