BestOwl / MyPhone

Connect your mobile devices (Android/iOS/WindowsPhone) to PC
MIT License
195 stars 38 forks source link

Incoming call handle #7

Closed vvtoan closed 3 years ago

vvtoan commented 3 years ago

Hi. I want to handle incoming call to display customer's informations in our crm. Is there any api can do that? When i use var result = await BTDevice.GetRfcommServicesForIdAsync(RfcommServiceId.FromUuid( new Guid("0000111F-0000-1000-8000-00805F9B34FB")),BluetoothCacheMode.Uncached);

            if (result.Services.Count > 0)
            {
                BTService = result.Services[0];
                var status = await BTService.RequestAccessAsync();
                BTSocket = new StreamSocket();
                await BTSocket.ConnectAsync(BTService.ConnectionHostName, BTService.ConnectionServiceName,
                    SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);

                _writer = new DataWriter(BTSocket.OutputStream);
                _reader = new DataReader(BTSocket.InputStream);

                return true;
            }
            else
            {
                Debug.WriteLine("This device does not support HFP");
                return false;
            }

I has an error 'DeniedBySystem'

Thanks you.

BestOwl commented 3 years ago

Is this a UWP or Win32 app?

BestOwl commented 3 years ago

The HFP demo here should work without errors.

vvtoan commented 3 years ago

Hi "Is this a UWP or Win32 app?": UWP app When i run HFP demo i get an error. image

BestOwl commented 3 years ago

You should run the Do() method instead.

DoTest is a demo to show how to use the PhoneLineTransportDevice API, which can only be called in an MSIX-packaged app. That's why you got this error in MyPhone.Demo because it is a Win32 .NET console app. I will document the demo code later.

For UWP apps, if you want to use the PhoneLineTransportDevice API, you need to add these permissions in the manifest: https://github.com/BestOwl/MyPhone/blob/5d0015dc7f49fe1b794b2e9f2c079498529717a2/MyPhone/Package.appxmanifest#L55-L57

vvtoan commented 3 years ago

This issues was resolved. Thanks you.