UWP项目用azure iot你们可以吗?
deviceClient = DeviceClient.Create("*******.azure-devices.net", new DeviceAuthenticationWithRegistrySymmetricKey("test1", "********"));
Message re = await deviceClient.ReceiveAsync();
while (true)
{
try
{
//这里会出错,提示没有 错误信息是, * 号 我 替换 的, 绝对 正确, 用 winform 项目 就 完美 运行, uwp 项目 不行,为什么 "Message":"ErrorCode:IotHubUnauthorizedAccess;Unauthorized","ExceptionMessage":"Tracking
ID:1768b326ef8a4a5aad3cb28d7ed91c65-G:0-TimeStamp:03/11/2017 17:12:20"}
Microsoft.Azure.Devices.Client.Message re = await deviceClient.ReceiveAsync();
if (re == null)
{
continue;
}
string msg = Encoding.ASCII.GetString(re.GetBytes());
if (msg == "on")
{
GpioController.GetDefault().OpenPin(10).Write(GpioPinValue.High);
}
else if (msg == "off")
{
GpioController.GetDefault().OpenPin(10).Write(GpioPinValue.Low);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}