Xamarin.Mac - 发送通知
Xamarin.Mac - Send notification
我正在尝试使用 Azure 通知中心和 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);
}
该库中有几个区域是 Windows 特定于桌面的,在 Mono、UWP、Win10 IoT 等上不可用。(CreateWaitableTimer
等项目是原生的 Windows 桌面 API 调用)。
Azure 有许多不同的客户端和库,最多 "portable" 是 REST api,发送 MPNS 本机通知涉及执行 POST 到:
https://{namespace}.servicebus.windows.net/{NotificationHub}/messages/?api-version=2015-01
文档显示了内容并且headers需要:
我正在尝试使用 Azure 通知中心和 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);
}
该库中有几个区域是 Windows 特定于桌面的,在 Mono、UWP、Win10 IoT 等上不可用。(CreateWaitableTimer
等项目是原生的 Windows 桌面 API 调用)。
Azure 有许多不同的客户端和库,最多 "portable" 是 REST api,发送 MPNS 本机通知涉及执行 POST 到:
https://{namespace}.servicebus.windows.net/{NotificationHub}/messages/?api-version=2015-01
文档显示了内容并且headers需要: