Xamarin.Mac Azure通知中心

问题描述:

我试图通过Xamarin.Mac制作的Mac App向iOS和Android设备发送通知。我有以下代码:Xamarin.Mac Azure通知中心

 notif_button.Activated += (sender, e) => { 
      NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString("<connection string>", "<hub name>"); 
      String pushMessage = "{ \"data\" : {\"msg\":\"" + Message + "\",\"param\":\"" + parameter + "\"}}"; 
      NotificationOutcome result = await hub.SendGcmNativeNotificationAsync(pushMessage); 
     }; 

的问题是,NotificationHubClient无法识别。有人知道为什么我试图添加“使用Microsoft.Azure ...”而没有成功。

您需要将Xamarin.Mac项目Target Framework更改为Xamarin.Mac Full对比的Xamarin.Mac Modern

enter image description here

默认一旦你这样做,你可以重新定位包到该框架:

enter image description here

现在Microsoft.Azure.NotifactionHub参考将显示下包的引用:

enter image description here

添加的using条款:

using Microsoft.Azure.NotificationHubs; 

现在,您可以访问NotificationHubClient类:

var hub = NotificationHubClient.CreateClientFromConnectionString("<connection string>", "<hub name>"); 
+0

厂像一个魅力,非常感谢! –