Reputation: 6403
I'm trying to receive push notifications from Azure's Notification Hub on Xamarin.Forms. I tried Azure's example for Android. The problem is, Azure's tutorial connects to the database which sends the notifications when database is changed. I don't want that. There's already a CMS in place that triggers the push notifications.
So how do I connect the app just to the Notification Hub and listen for the notifications?
Upvotes: 1
Views: 3024
Reputation: 6403
Found the solution. I had to register with Azure notification hub too. If someone is stuck, follow this:
Or, follow the example given in Xamarin's "Azure Messaging" component here: https://components.xamarin.com/gettingstarted/azure-messaging
Upvotes: 1
Reputation: 613
I am actually doing this right this very second. Not with Xamarin but with a Windows Phone app. Hopefully this can help.
Add code to associate your app with the notification hub
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
var hub = new NotificationHub("", ""); var result = await hub.RegisterNativeAsync(channel.Uri);
That can go in the OnLaunched event in the App.xaml.cs. This will register the app with the hub. Make sure you choose the type of notification the app will show in the package manifest (toast..etc..)
This is written up in detail at the following url https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-windows-store-dotnet-get-started/
There are some other good docs if you don't want to notify everyone, such as notify just subscribers of a category. Hope this helps. It might not be 100% on point with Xamarin but should be close.
Upvotes: 0