Xamarin.Mac Azure Notification Hub

82 Views Asked by At

I'm trying to send notification to iOS and Android devices through a Mac App made with Xamarin.Mac. I've the following code:

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

The problem is that NotificationHubClient is not recognised. Anyone know why ? I tried to add "using Microsoft.Azure..." without success.

1

There are 1 best solutions below

0
On BEST ANSWER

You need to change the Target Framework of your Xamarin.Mac project to Xamarin.Mac Full vs. the default of Xamarin.Mac Modern

enter image description here

Once you do that, you can retarget the packages to that framework:

enter image description here

Now the Microsoft.Azure.NotifactionHub reference will show up under the package references:

enter image description here

Add a using clause of:

using Microsoft.Azure.NotificationHubs;

Now you can access the NotificationHubClient class:

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