2017-09-07 3 views
1

Ich versuche Push-Benachrichtigungen mit Azure Notification Hub und Xamarin.Mac zu senden. Ich habe diesen Fehler, und ich weiß nicht warum. Jemand kann mir helfen, damit umzugehen?Xamarin.Mac - Benachrichtigung senden

Der Fehler:

System.TypeInitializationException: The type initializer for 'TimerManager' threw an exception. ---> System.EntryPointNotFoundException: CreateWaitableTimer 

Mein Code:

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); 
} 

Antwort

2

Es gibt mehrere Bereiche dieser Bibliothek, auf dem Windows-Desktop sind spezifisch und sind nicht auf Mono, UWP, Win10 IoT usw. (Elemente wie CreateWaitableTimer sind native Windows Desktop API-Aufrufe).

Azure eine Reihe von verschiedenen Clients und Bibliotheken haben, das „portable“ ist das REST-API, das Senden eine MPNS india Mitteilung beinhaltet eine POST durchführt:

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

docs zeigt den Inhalt und Header erforderlich :

+0

Vielen Dank für Ihre Antwort, werde ich den REST-aPI verwenden. Es scheint, dass es die beste Lösung für mein Problem ist :) Vielen Dank! –

Verwandte Themen