Microsoft Band SDK Preview - 后台任务中的 NotificationManager
Microsoft Band SDK Preview - NotificationManager within a backgroundtask
嗨,我不确定我是否遗漏了什么,或者这是否不在 API 范围之内,在我看来这似乎是短视的。
SDK 可以在后台任务中向手环发送通知吗?这对我来说似乎是最有用的东西之一,但是当我尝试时出现错误。 'bandClient.NotificationManager.SendMessageAsync' 是它抛出异常的地方。后台任务为定时任务
后台代码简单,我在后台和UI线程上试了一下
尝试
{
// Get the list of Microsoft Bands paired to the phone.
IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();
if (pairedBands.Length < 1)
{
deferral.Complete();
}
// Connect to Microsoft Band.
using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
{
await bandClient.NotificationManager.SendMessageAsync(myTileId, "Earnings", currentDollars.ToString(), DateTimeOffset.Now, f);
}
}
catch (Exception ex)
异常和堆栈跟踪:
ex = {System.Exception: Catastrophic failure (Exception from HRESULT:
0x8000FFFF (E_UNEXPECTED))
at Windows.UI.Xaml.Application.get_Current()
at Microsoft.Band.BandClientManager.d__2.MoveNext()
--- End of stack trace from previous location...
at Windows.UI.Xaml.Application.get_Current()
at Microsoft.Band.BandClientManager.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at
WindowsRuntimeComponent1.AppTileUpdater.d__8.MoveNext()
是的,目的是您应该能够从后台任务连接到 Band 并对其进行操作。但是,Band SDK 预览版(1.3.10219-预览版)存在一个已知问题,该问题会阻止在后台任务中的代码 运行 中创建 IBandClient。
新版本中的后台任务(以及很多其他内容)已在今天停止预览。
嗨,我不确定我是否遗漏了什么,或者这是否不在 API 范围之内,在我看来这似乎是短视的。
SDK 可以在后台任务中向手环发送通知吗?这对我来说似乎是最有用的东西之一,但是当我尝试时出现错误。 'bandClient.NotificationManager.SendMessageAsync' 是它抛出异常的地方。后台任务为定时任务
后台代码简单,我在后台和UI线程上试了一下
尝试
{
// Get the list of Microsoft Bands paired to the phone.
IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();
if (pairedBands.Length < 1)
{
deferral.Complete();
}
// Connect to Microsoft Band.
using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
{
await bandClient.NotificationManager.SendMessageAsync(myTileId, "Earnings", currentDollars.ToString(), DateTimeOffset.Now, f);
}
}
catch (Exception ex)
异常和堆栈跟踪:
ex = {System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at Windows.UI.Xaml.Application.get_Current()
at Microsoft.Band.BandClientManager.d__2.MoveNext()
--- End of stack trace from previous location...
at Windows.UI.Xaml.Application.get_Current()
at Microsoft.Band.BandClientManager.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at WindowsRuntimeComponent1.AppTileUpdater.d__8.MoveNext()
是的,目的是您应该能够从后台任务连接到 Band 并对其进行操作。但是,Band SDK 预览版(1.3.10219-预览版)存在一个已知问题,该问题会阻止在后台任务中的代码 运行 中创建 IBandClient。
新版本中的后台任务(以及很多其他内容)已在今天停止预览。