0
votes

I have successfully created a Xamarin Forms project and have got the full lifecycle of registration of GCM push notifications, forwarding of the GCM registration token to Azure Notification hubs (ANH) and reception of notifications sent/published via Azure Notification Hub.

I've achieved this using the Quickstart Mobile App Service within the Azure console and adapting the downloaded skeletal mobile client app to register with GCM and forward the registration with ANH as per this tutorial.

Push notifications for Xamarin forms using Azure Notification Hub and Mobile services

I now want to remove the dependency from Azure's mobile app service and instead handoff the registration to the Notification hub directly. There is a good tutorial on how to do this on an Android native SDK project here :

Android mobile client - push notifications using Azure Notification Hub

In the supplied Java code the notification hub registration is done using API calls using the API/library made available with this Java import statement

import com.microsoft.windowsazure.messaging.NotificationHub;

I am trying to take the exact same approach in a Xamarin forms project by adding a NuGet package reference and a using directive but I cannot seem to be able to add the NuGet the package Microsoft.Azure.NotificationHubs to the Droid project. From what I can see this assembly is geared towards backend.

My question is two-fold -:

  1. Does my approach make sense ? Am I making life hard for myself by trying to eliminate the integration of my mobile app with Azure mobile services. I don't need bells and whistles like offline sync right now and I wanted to (for now) integrate my push notification code into existing Xamarin forms project/solution.

  2. Is there another approach to providing me in Xamarins forms C# wrapped code for Android to register my device for push notifications with Azure without being mediated through the mobile services backend ?

(Update: I noticed that for Windows 8 Phone and Windows Store Apps there is a nuget component called WindowsAzure.Messaging.Managed which provides access for registration of apps to the Azure notification hub but once again this isn't available for the Droid subproject within the Xamarin forms solution)

1

1 Answers

0
votes
  1. You approach totally makes sense, Azure Notification Hubs were created just to send notifications in a scalable and reliable way.
  2. There is a tutorial about using Azure Notification Hubs in Xamarin apps on Android - https://azure.microsoft.com/en-us/documentation/articles/xamarin-notification-hubs-push-notifications-android-gcm/. I hope this tutorial will help you.