AppCenter Push Notification – Part 1

App Center Push allows you to engage your users by sending them targeted push notifications. We will start with the android example in this article.

Firstly you will have to set up the platform specific push services. We need to create a new project in fireabase console then we can get SenderID and Server Key in Configuration > Cloud Messaging tab. we will do all the operations on the Firebase

We have to create a new app on appcenter. (OS Android and Platform Xamarin)

Now, we should set up our Android spesific codes and add the App Center Push SDK

using Microsoft.AppCenter;
using Microsoft.AppCenter.Push;

Search for App Center and App Center Push and add both packages by clicking Add Packages.

We need to initialize AppCenter in App.cs > OnStart method. But if you use Xamarin.Forms you have to get Xamarin.Forms keys otherwise you can use Xamarin.Traditional key.

Now we can edit AndroidManifest.xml and insert the following elements before the <application> section;

<permission android:protectionLevel=”signature”
android:name=”${applicationId}.permission.C2D_MESSAGE” />
android:name=”${applicationId}.permission.C2D_MESSAGE” />

If you are using Xamarin.Forms, you need to set the Sender ID in your MainActivity.cs file, in the OnCreate method, before the LoadApplication call

LoadApplication(new App());

Now we are on last step and we can set the server key and save our settings.

AppCenter is giving us very skilled events. When notification is received, PushNotificationReceived event is triggered and giving us notification details.

Let’s try!

Congratulations! You sent your first notification

It’s really easy to send notifications with AppCenter. I will continue writing about AppCenter.


Xamarin Developer, Consultant & Architect. Community Leader and Director of Xamarin Türkiye

Post A Reply