2017-08-31 85 views
1

我試圖通過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 ...」而沒有成功。

回答

2

您需要將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

廠像一個魅力,非常感謝! –

相關問題