Geoff James
Geoff James

Reputation: 3180

Make telephone call from Windows Store App C# WinRT

I am developing a Windows Store App using WinRT in C#.

I want to create a button or a link that the user can click/tap, and the device's default app to make phone calls is used.

Better still, if the user could choose the app to use (if more than one is installed), that would be good, too.


I am looking for a similar behaviour to how you can click a tel://01234567890 link from a web browser, and the browser hands this off to the phone/device so the user can call it.

With that in mind -


Searching around I have found everything for Windows Phone 8.1 so far. But nothing for Windows Store Apps using Windows RunTime in Win 8/8.1.

Please note: I am not specifically looking to make the call from within the app, more so to open the default app the device uses. However, I am open to options, so if there is also a way to do it from within the app, I would consider that, too.


Is this possible? Is there an API or Library that I might need?

Thank you in advance.

Upvotes: 0

Views: 305

Answers (2)

lindexi
lindexi

Reputation: 4327

@Geoff have a Good answer and I have another.

You can use the PhoneCallManager to call when device is mobile and use Skype to call when device is pc.

If the device is mobile and you can use the Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI to call the number.And it's checked the device is mobile.

if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile")
{
    Windows.ApplicationModel.Calls.PhoneCallManager
           .ShowPhoneCallUI("The number you call",
                            "The pople's name that is the number ower");
}

It's like that
(source: 9uads.com)

When you use it,you should include Windows Mobile Extensions

And if your device is pc,you also can use the Skype to call.

private async void Button_OnClick(object sender, RoutedEventArgs e)   
{
    Uri url=new Uri(@"Skype:number?call");
    var areSkypeCall = await Windows.System.Launcher.LaunchUriAsync(url);
    if (areSkypeCall)
    {
        //Success
    }
}

The format of Uri is "Skype:"+number+"?call" or "Skype:"+skype id+"?call".

See UWP use skype to call number

Upvotes: 0

Geoff James
Geoff James

Reputation: 3180

I managed to come up with a solution to get the described behaviour as in the question.

I used the same tel:// "link" concept as I was talking about in my question.

The solution I came up with:

  • create a URI
  • launch it from the app
  • the device then handles opening the URI; asking which app to use if necessary

This was as simple as one line:

private async Task MakePhoneCall(string phoneNumber)
{
    await Launcher.LaunchUriAsync(new Uri($"tel://{phoneNumber}"));
}

The Launcher static class is found in the Windows.System namespace (using Windows.System;).

Hopefully this will help someone else in the future :)

Upvotes: 1

Related Questions