Send a Push Notification from Business Central to ANDROID by using Azure Notification Hub and a Xamarin Form app.


  • In Business central we have a “Messages” table where there are messages to be dispatched to mobile devices;
  • In the Business Central we have a page where the user sends a push notification to the sales agents;
  • The sales agents receive the Push Notification containing the message in the Android App;



  • A simple Xamarin Forms app;
  • An Azure Function;
  • An Azure Notification Hub account;
  • A Firebase Google Cloud Messaging or a Google Cloud Messaging account (*);
  • A Business Central Extension;
  • In this sample I am not using Azure Vault to store passwords and I just use settings.json, you should when in production environment 🙂

* Pay attention, GCM Google Cloud Messaging is not FCM Firebase Cloud Messaging. FCM and GCM are two different services to send push notifications available on the Google Messaging platform. The GCM is deprecated and the FCM is the new one. In this tutorial I cover both services since unfortunately you might have, as me, some apps already configured with GCM that cannot be migrated to FCM.

There’re two kind of notifications in FCM: Data messages and Notification messages.

If you are using the Data messages you will be in charge of handling the received message and present a notification to the user (if needed of course). But in this case you might miss notifications when your app is closed.

If you are using Notification Messages, FCM is handling the message for you and directly displays a notification if the app is in background/closed.

Check here for differences:


The Xamarin Forms sources are available from GitHub.

The solution I made for you in GitHub is already configured. If you start with your own project you have to do a lot of things like: add Xamarin.GooglePlayServices.Base, Xamarin.Firebase.Messaging Xamarin.Azure.NotificationHubs.Android nuget packages, add google-services.json to your project and set it as Build Action = “GoogleServiceJson”, change AndroidManifest.xml and properly add <uses-permissions> and <receiver> tags.

You have the full procedure available here:

As in my solution, the packages list should appears as in picture, the google-service.json must be properly added and Android.Manifest.xml modified as shown below.

Te Xamarin Forms project is a simple single page app that just register and waits for a push notification.

The Xamarin Forms basically consists in three functions and all of then are in the AppDelegate.cs file.

Firstly the app checks the presence on device of Google Services and registers itself to the Firebase FCM Notification Service..

MyFirebaseMessagingService is the function that manage the push notification behaviour.

The Azure Hub Notification endpoints have to be configured in AzureNotificationConstants.cs

Documentation about different ways of implementing Firebase Notification in Xamarin Android app is available here:


The Xamarin Forms sources are available from GitHub:

The Azure Function is pretty simple too. It wait for a GET request with the message as a query parameter. When it is called it dispatch the message by using NotificationHubClient.


The Business Central extension sources are available from GitHub:

The extension consists in very simple table with a page card and a page list that allow CRUD for records.

The codeunit “Cod70359948.ALV Send Push” contains the SendPush function that calls the Azure Function to send the messages.


Take a seat, be patient, drink a calming herbal tea because this chapter is quiet long 🙂

Please notice that the procedure of google GCM often changes so, at the time you are reading, this section might already be out of date. In case check this link

Firstly, open Google Developer Console ( and access with your credentials.

Insert your project Name and click “Create”. Click on alert button on top bar and select the project from the list. You are redirected in the project dashboard page.

In the project dashboard there is the “Project Number”. Note this number because you will need in next steps.

Find the API section inside dashboard page and click on “Go to APIs overview”.

You are now in API page, here click on “Enable APIs and Services”.

Search, find and select “Google Cloud Messaging” or “Cloud Messaging”.

Click “Enable”

Select “Create credentials” on the tool bar.

You are redirected in “Add credential to your project” page, here you click “API key” shortcut.

You are redirected in “API Key” page. Here select Create/Save. Here configure as in picture, by selecting “IP addresses” option with address. For your security here you should insert the IP address your azure function is assigned to when created in Azure Portal.

A dialog appears with your own API Key. Save it somewhere because we will use it in Azure. This KEY is used on Azure Portal to authenticate on GCM services to send push notifications.


Go to FCM Firebase Cloud Messaging Console:

Select previous created project and select “Add Firebase to your Android App”.

Digit your android package name.

Click on “Register app” and download your “google-services.json”.

Skip the test by ignoring app verification.

Go to “Project Overview” and select “Project settings”.

Write down the Web API Key somewhere, you will need it when configuring your Xamarin Forms app.

Go to Cloud Messaging tab, there write down the “Server key”, you will need it when configuring in Azure Portal.


In Azure Portal, you create are resource “Notification Hub”.

Create the resource group, insert your namespace and hub name.

Wait Azure completes the creation of the resource, then edit the notification hub just created and go to “Settings” -> “Google (GCM/FCM)” section.

If you are using GCM paste here your GCM “Api key” as saved in previous section (GCM).

If you are using FCM paste here FCM “Server Key” as saved in previous section (FCM).


In your Xamarin Forms solution, open AzureNotificationConstants.cs and copy the ListenConnectionString and the hub name.

Open Azure Function in Visual Studio Code, edit the “local.settings.json” file and copy the connection string and HubName here too.


This solution send broadcast messages, I will publish soon a complete solution where it is possibile to send a message to a specific user.


18th April 2020

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s