2017-09-07 34 views
1

我试图用Azure通知中心和Xamarin.Mac发送推送通知。 我有这个错误,我不知道为什么。有人可以帮我处理它吗?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); 
} 

回答

2

但是也有一些Windows桌面,因此未提供单声道,UWP,Win10物联网等该库的几个方面(像CreateWaitableTimer这样的项目是本机Windows桌面API调用)。

Azure中有许多不同的客户端和库的,最“便携”是REST API,发送MPNS本地通知涉及执行POST到:

https://{namespace}.servicebus.windows.net/{NotificationHub}/messages/?api-version=2015-01 

该文档显示所需的内容和标题:

+0

谢谢您的回答,我会使用REST API。它似乎是我的问题的最佳解决方案:)非常感谢! –