Skip to content

TransportDevice.ConnectAsync() not working on Windows Form application. #28

@PongManao

Description

@PongManao

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions