build 2016 - p542 - windows calls applications
Post on 13-Jan-2017
162 Views
Preview:
TRANSCRIPT
#Build2016
Windows Calls Applications(windows.applicationmodel.calls)
Bayo OlatunjiProgram ManagerSage SchreinerProgram Manager
Introduction to Calls APIPublic Calls API• Available for UWPs in Windows 10 Fall release• Mobile extension SDK• Replaces the older Silverlight PhoneCallTask()• The Microsoft ‘Phone’ dialer app uses this public API
Features• Allows initiating a cellular call without a per-use UI consent• Supports dual-SIM phones• Includes common telephony events and background task triggers
//build2016
Calls Applications
A dialing application, or application that includes calls functionality will generally:• Enumerate available lines, and identify the intended line – could be as
simple as ‘default’ or as complex as a picker provided to the user.• Dial() or DialWithOptions() on the line in question.• Pass a phone number that it acquired via Contacts, Call History, a dial
pad, or other means.• Register for any needed background task triggers.
//build2016
Documentation
windows.applicationmodel.calls is the namespace for telephony APIs, including this one.
API documentation available at: https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.calls.aspx
Complete sample application found at:https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/PhoneCall
//build2016
Windows Calls Applications
//build2016
Get a Line / Defaults / Multi-line aware
Enumerate lines• A multi-line aware dialing app enumerates available lines on a given
device.• A line (usually) correlates to a SIM slot• Dial() and DialWithOptions() are always called on a line
Line propertiesReturned line properties include:• The OS “friendly name” and color associated with the line• Current line network status• Whether a line can dial out calls
//build2016
Demo
Bayo Olatunji
Get Lines/// <summary> Enumerate through all phone lines and returns a list of all phone lines </summary>/// <returns> A dictionary of cellular phone lines and their guids. </ returns> private async Task<Dictionary<Guid,PhoneLine>> GetPhoneLinesAsync(){
PhoneCallStore store = await PhoneCallManager.RequestStoreAsync();// Start the PhoneLineWatchervar watcher = store.RequestLineWatcher();var phoneLines = new List<PhoneLine>();var lineEnumerationCompletion = new TaskCompletionSource<bool>();watcher.LineAdded += async (o, args) => { var line = await PhoneLine.FromIdAsync(args.LineId); phoneLines.Add(line); };watcher.Stopped += (o, args) => lineEnumerationCompletion.TrySetResult(false);watcher.EnumerationCompleted += (o, args) => lineEnumerationCompletion.TrySetResult(true);watcher.Start();// Wait for enumeration completionif (!await lineEnumerationCompletion.Task){
throw new Exception("Phone Line Enumeration failed");}watcher.Stop();Dictionary<Guid,PhoneLine> returnedLines = new Dictionary<Guid,PhoneLine>();foreach (PhoneLine phoneLine in phoneLines){
if (phoneLine != null && phoneLine.CanDial{
returnedLines.Add(phoneLine.Id,phoneLine);}
}return returnedLines;
}
//build2016
Get Default Line
/// <summary> Gets the default phone line </summary>/// <returns> A one phone line. The default one on the device. </returns> private async Task<PhoneLine> GetDefaultPhoneLineAsync(){
PhoneCallStore phoneCallStore = await PhoneCallManager.RequestStoreAsync();Guid lineId = await phoneCallStore.GetDefaultLineAsync();return await PhoneLine.FromIdAsync(lineId);
}
//build2016
Dial a CallTwo Dial Methods • Dial() and DialWithOptions()• Both methods are always called on a line• Dial() is used for simple dialing actions with only the Phone number as a parameter• DialWithOptions() may be used when additional flexibility is required
such as: initiating a call on speakerphonecalling a specific component contactsetting a display name for the target phone number
• (For now on we’ll just refer to Dial(), but we mean either of the two APIs, Dial() or DialWithOptions())
//build2016
Demo
Bayo Olatunji
Dial()/// <summary> Dials a phone number with the display name on the current phone line. </summary>/// <param name="PhoneNumber"> The phone number to dial </param>/// <param name="DisplayName"> The display name to show in the UI </param>public async void DialOnCurrentLineAsync(string PhoneNumber, string DisplayName){
if ((currentPhoneLine != null) && (PhoneNumber.Trim().Length > 0)){
currentPhoneLine.Dial(PhoneNumber, DisplayName);}else{
var dialog = new MessageDialog("No line found to place the call");await dialog.ShowAsync();
}}
//build2016
DialWithOptions()/// <summary> Dials a phone number with with options on the current phone line. </summary>/// <param name="PhoneNumber"> The phone number to dial </param>/// <param name="DisplayName"> The display name to show in the UI </param>public async void DialOnCurrentLineWSpeakerphoneAsync(string PhoneNumber, string DisplayName){
if (( currentPhoneLine != null) && (PhoneNumber.Trim().Length > 0)){
// Populate phone dial options with number, display name, and an audio endpoint.
PhoneDialOptions callingOptions = new PhoneDialOptions();callingOptions.Number = PhoneNumber;callingOptions.DisplayName = DisplayName;callingOptions.AudioEndpoint = PhoneAudioRoutingEndpoint.Speakerphone;currentPhoneLine.DialWithOptions(callingOptions);
}else{
var dialog = new MessageDialog("No line found to place the call");await dialog.ShowAsync();
}}
//build2016
Background Task Triggers
NewVoicemailMessageThe system received a new voice mail message or the voice mail count went to 0.
CallHistoryChanged The call history has changed.
LineChanged The PhoneLineProperties have changed.
//build2016
Windows Calls Applications
//build2016
A Few Notes…Considerations• Applications that make use of the Calls APIs must declare “phoneCall” in manifest.• Applications must have UI present in the foreground when Dial() is called
Win10 & Publication in China• If your Calling application manifest MinOS supports the Win10 Fall 2015 OS release
(10586), your application will initially fail Store certification in China.• Contact your premier support representative if you need a waiver to publish in China
Windows next Privacy Control• New per-app privacy functionality for Windows next that allows users to control access to
Dial() for easy publication in China• Just like Calendar, Email, Contacts, Location etc…
//build2016
Related Functional AreasCall History• Call history APIs are supported for Dialer applications that would like to provide a view
of the OS call history database.• Applications will need to declare phoneCallHistoryPublic in manifest.• Documentation and Build 2015 videos available online:
https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.calls.aspx https://channel9.msdn.com/Events/Build/2015/2-684
Call Origin, Spam FilterSamples and documentation available online:
https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.calls.aspx https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CommunicationBlockAndFilter https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CallerID //build2016
Forward Thinking
Help us prioritize – please make your voice heard! (https://wpdev.uservoice.com/)
Call Control – Answer, Hangup, Conference, Forward, InformationIn-call application launch – Launch an app from the call UIIn-call UI extension – Write to a surface in the in-call UISupport additional Windows platforms – Xbox, Hololense and more…
//build2016
Thank you!
//build2016
top related