Implement PUSH notifications in Xamarin Android APP with PortSIP PBX 12.x
This guide gives you step-by-step instructions on how to implement the PUSH notifications in the SIPSample project of PortSIP VoIP SDK which can receive VoIP push notifications sent with PortPBX 12.x.
- The App is automatically relaunched if it’s not running when a VoIP push is received
- The Device is woken up only when VoIP push occurs (to save battery)
- VoIP pushes go straight to your app for processing and are delivered without delay
- The App is automatically relaunched if it’s not running when a VoIP push is received
Since PortSIP PBX uses the Google Firebase to send PUSH notifications, we need to configure some settings to get this working.
Add a new project to the Firebase console.
You will need to set the project name and country. For example, I will call my project SIPSamplePush.

Select "Add Firebase to your Android app".
Set a package name for your app. I only set my package name and omit the SHA-1 because I don't use Firebase for my app's authentication.

Click the REGISTER APP button here to download google-services.json. This is an important file and you will need to put it into your app.
Important: Please note that the Android package name is also referred to as “App ID”. We will use it in future settings.
Since Firebase Cloud Messaging is dependent on Google Play Services, the Xamarin Google Play Services - Base package must be added to the Xamarin.Android project. You will need version 212.0.0.2 or later.
- 1.In Visual Studio, right-click References > Manage NuGet Packages ...
- 2.Click the Browse tab and search for Xamarin.GooglePlayServices.Base.
- 3.Install this package into the Portsip.Android.Test project:

If you get an error during the installation of the NuGet, please close the Portsip.Android.Test the project, open it again, and retry the NuGet installation.
Note: If the problem persists with the error message “Unable to install package: “Xamarin.GooglePlayServices.Base xx.xxxx.x”, it indicates that you are trying to install this package into the target project “MonoAndroid,Version=vx.0”, while the package does not include any assembly references or content files to be compatible to this framework. For more details, please contact the package author. Please start the Visual Studio installer to upgrade to the latest version. Once upgraded, right-click the project, click Properties > Target Framework to choose the latest platform. After this, repeat Step 3.
When you install Xamarin.GooglePlayServices.Base, all of the necessary dependencies are also installed. Edit MainActivity.cs and add the following using statement:
using Android.Gms.Common;
This statement makes the GoogleApiAvailability class in Xamarin.GooglePlayServices.Base available to Portsip.Android.Test code. GoogleApiAvailability is used to check for the presence of Google Play Services.
To receive messages from FCM, the Xamarin Firebase - Messaging package must be added to the app project. Without this package, an Android application cannot receive messages from FCM servers.
1. In Visual Studio, right-click References > Manage NuGet Packages ...
2. Check Include prerelease and search for Xamarin.Firebase.Messaging.
3. Install this package into the Portsip.Android.Test project:

When you install Xamarin.Firebase.Messaging, all of the necessary dependencies are also installed.
Next, edit MainActivity.cs and add the following using statements:
using Firebase.Messaging; using Firebase.Iid; using Android.Util;
The first two statements make types in the Xamarin.Firebase.Messaging NuGet package available to PortSip.Android.Test code. Android.Util adds logging functionality that will be used to observe transactions with FMS.
The next step is to add the google-services.json file to the root directory of your project:
- 1.Copy google-services.json to the project folder.
- 2.Add google-services.json to the app project (click Show All Files in the Solution Explorer, right click google-services.json, then select Include in Project).
- 3.Select google-services.json in the Solution Explorer window.
- 4.In the Properties pane, set the Build Action to GoogleServicesJson (if the GoogleServicesJson build action is not shown, save and close the Solution, and reopen it):