我正在尝试使用Azure Notification Hub和Xamarin.Mac发送推送通知。 我有这个错误,我不知道为什么。有人可以帮我处理吗?
错误:
System.TypeInitializationException: The type initializer for 'TimerManager' threw an exception. ---> System.EntryPointNotFoundException: CreateWaitableTimer
我的代码:
private static async void SendNotificationAsync()
{
NotificationHubClient hub = NotificationHubClient
.CreateClientFromConnectionString("<connection string>", "<hub name>");
string toast = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>Content</wp:Text1>" +
"</wp:Toast> " +
"</wp:Notification>";
await hub.SendMpnsNativeNotificationAsync(toast);
}
答案 0 :(得分:2)
该库的某些区域是特定于Windows桌面的,并且在Mono,UWP,Win10 IoT等上不可用。(CreateWaitableTimer
之类的项目是本机Windows桌面API调用。)
Azure有许多不同的客户端和库,最“可移植”的是REST api,发送MPNS Native Notification涉及执行POST:
https://{namespace}.servicebus.windows.net/{NotificationHub}/messages/?api-version=2015-01
文档显示了所需的内容和标题: