1
votes

I am embarking on setting up a Xamarin Forms project for proof of concept with an aim of having an Android app running in the Android emulator registering and receiving google cloud notifications sent via Azure's notification hub.

In researching this I have found some sample code which assumes a backend which uses Microsoft Azure's Mobile Services back end. I'd prefer not to have a dependency in my client code on Mobile Services backend if possible. However, maybe this is unavoidable (or inadvisable) when using Azure Notification Hubs. That is really the central issue I am raising with this question.

The tutorial linked below shows an approach to register and receive notifications using a Xamarin forms app which is dependent on the Azure Mobile Services backend.

https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-xamarin-forms-get-started-push/

Whereas, this second tutorial shows an approach where the mobile client app (developed using Xamarin Android) registers to the Google messaging cloud rather than Azure notification hubs).

https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote_notifications_in_android/

Where I am coming unstuck is trying to figure out which is the right approach to enabling a Xamarin forms app to register and receive notifications which are pushed via Azure notification hub. Will the approach of the 2nd tutorial (device registers for push notifications directly with Google cloud) work when notifications are sent via Azure Notification Hubs (configured with the correct API credentials for google messaging) or am I missing something ?

In other words am I making life difficult for myself by adopting the 2nd approach ?

My focus is on developing using Xamarin forms but with Android as the lead device type for initial prototype , proof of concept and then moving on to iOS and Windows Universal 10 at a later stage.

1

1 Answers

2
votes

My 2 cents.

The whole point of using Azure Notification Hubs is to abstract away the need to handle Google and iOS push notification systems. Since you are planning to eventually do both iOS and Android, I would suggest registering through Azure.

Azure will handle the iOS feedback channel when registering devices which is nice and you are able to use message templates in Azure which means you can send a single notification hub message and it will be automatically transformed into a message that Android's GCM expects to see and another message that iOS' APNS expects to receive (they both expect different notification message formats).

Since it sounds like no matter which option you choose, you are planning to send messages through Azure, you are going to have to deal with the same Notification Hub limitations, meaning you do not gain much from registering directly through the native server interfaces (limitations in the number of tags a message can have is what I am mainly thinking about).

There is also a library for both platforms if you want to register directly from the device or you can, like we did, have the mobile device call one of your own backend server which can do some initial processing before sending the registration request to azure for the device.

*Edit: Though if you just want to get something working, I do not see a problem with registering directly to GCM and then later on switching out the code to do it through Azure later on.