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 -
On phones it tends to be the phone app, or an option to choose if there is more than one app that can make calls
On PCs where an app is installed that can make calls (eg Skype), clicking a tel://
link tends to open it by default through that (browser usually asks beforehand)
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.
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:
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 :)
@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 http://jycloud.9uads.com/web/GetObject.aspx?filekey=c0df6586a5d486d0ce7cd9447fd75f59
When you use it,you should include Windows Mobile Extensions
http://jycloud.9uads.com/web/GetObject.aspx?filekey=9913efb448c7510d822e4c6dcc570c55
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".
http://jycloud.9uads.com/web/GetObject.aspx?filekey=9913efb448c7510d822e4c6dcc570c55
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.