Handle receiving of push notifications in .NET MAUI (Android)

    If you didn't know how to implement push notification on Android see my posted Push notification in .NET MAUI (Android).

    After receiving notifications from Firebase Cloud Messaging, so how to handle those notifications e.g navigating to specific page, ...

 In this article, i will share with you guys the way i used to handle received notifications from Firebase Cloud Messaging.

    To handle the scenario when a user taps on a notification from the notification tray on Android, you need to implement a specific logic code in 2 override methods, OnCreate (when your app is closed) and OnNewIntent (when your app is active or in a foreground) in MainActivity.cs

    See the following code below for better understanding:

    Set LaunchMode = LaunchMode.SingleTop, it not you may get an error when tapping on a notification in case app is active.    

You can set or get your data via Intent and use this data to execute the necessary actions accordingly.