MyPhone
MyPhone copied to clipboard
TransportDevice.ConnectAsync() not working on Windows Form application.
I've tried to follow the codes in project "MyPhone" which is an UWP app to build a Windows Form app for making phone call. I've stuck in a trouble where TransportDevice.ConnectAsync() always returns 'false', so phone line cannot be initialed. Can anyone explain or guide me to the correct implementation of Windows Form?
Here are my codes:
protected override async Task<bool> ConnectToServiceAsync()
{
var accessResult = await TransportDevice.RequestAccessAsync();
if (accessResult == Windows.Devices.Enumeration.DeviceAccessStatus.Allowed)
{
//_logger.LogInformation("PhoneLineTransportDevice access granted");
}
else
{
//_logger.LogWarning("PhoneLineTransportDevice access denied, reason: {Reason}, contine anyway", accessResult);
}
if (!TransportDevice.IsRegistered())
{
//_logger.LogInformation("PhoneLineTransportDevice not registered, registering.");
TransportDevice.RegisterApp();
}
//_logger.LogInformation("PhoneLineTransportDevice registered.");
bool success = await TransportDevice.ConnectAsync();
if (success)
{
//_logger.LogInformation("CallService connected.");
//_logger.LogInformation("Initiate PhoneLine auto discovery.");
_taskInitPhoneLine = InitPhoneLine();
}
else
{
//_taskInitPhoneLine = InitPhoneLine();
}
return success;
}