Some background... I am building a Xamarin.Forms mobile application to allow monitoring of energy data from a device located at a user's home (which is pushed to a backend and stored every minute). From my (Azure Worker Role) backend I want to be able to send push notifications via Azure Notification Hub. Sometimes I'll want to push to all devices, sometimes, to groups, and sometimes to individual devices (I believe 'tags' are the way to do this). I currently have an Azure Notification Hub configured and I can send test messages (from the Azure portal) to all the iOS devices I am using for testing.
What I'm having trouble doing is figuring out how to register each device with the Notification Hub. What I want to happen is that when the user logs in to the mobile app, the device 'handle' (or device token) is passed back to the server. This can then be saved on the backend, and used to register the device using code based on the example provided at https://msdn.microsoft.com/en-us/library/azure/dn743807.aspx and Registering device on Azure Notification Hub from ASP.NET, as well as make changes to the associated 'tags' on the backend. I can then grab the device handle from the Worker Role if I need to send a notification to an individual device, or group of devices.
I have found a number of examples that all seem to be missing that vital piece of information for me to get this working. Most examples I've found seem to use rely on the use of Azure Mobile Apps (and the MobileServiceClient class), but I'm using a 'regular' MVC5 ASP.NET Web App. I've noticed with both Mobile Apps and Web Apps the Azure portal allows me to configure "Push", so presumably I can support push from either. I tried adding a RegisterController to my Web App, but this didn't seem to help when calling:
var push = PushNotificationsManager.DefaultManager.CurrentClient.GetPush();
push.RegisterAsync(deviceToken, templates);
based on the code sample provide at: https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-push#create-hub. Where the push client is:
client = new MobileServiceClient("http://mywebapp.azurewebsites.net");
What endpoint is the RegisterAsync attempting to call? I get no error.
Registering device on Azure Notification Hub from ASP.NET seems to be suggesting that I need to add a RegisterController to my Web App, but it doesn't show the Xamarin.Forms code to call this.
So, how do I register a mobile device from a Xamarin.Forms app with an Azure Notification Hub, via an MVC5 Web App?