Quick Links

Xamarin Forms: Load a contentpage when tap push notification android

I completed receiving test notification from FCM console. Now I am trying to open a page when tapping the notification. Any ideas about how to achieve this? I have searched the internet but can't find a working solution. I am also able to send the notification through the postman.

AppGcmListenerService is his own class inherited from the FirebaseMessagingService where you placed the OnMessageReceived method.
You should focus on the SendNotification, it can't be omitted. When your notification comes the OnMessageReceived will fire immediately without clicking the notification.

This tells the system what should be shown on the notification and what activity should be opened when the user clicks the notification. But this is configured on the Android side, we still choose the MainActivity as the initialized activity and pass the parameters there.
At last in the MainActivity's OnCreate event. We could get the parameters through

@Sreeee If your app is on quit state. The notification can't be received on Android.
However, if it is on foreground and background but it can't show the notification correctly. It means you haven't configured the SendNotification correctly.
You should call my code above in the OnMessageReceived method:

OnMessageReceived method and SendNotification methods are invoked only when the app is in the foreground. When the app is in the background code execution not entering to OnMessageReceived or SendNotification().

@Sreeee This may be because you are using a notification message.
Notification messages will only trigger the OnMessageReceived() method when your app is on foreground state.
Data messages will call OnMessageReceived() method no matter whether it is on foreground, background or killed.
So please check your notification payload.

@LandLu said:@Sreeee This may be because you are using a notification message.
Notification messages will only trigger the OnMessageReceived() method when your app is on foreground state.
Data messages will call OnMessageReceived() method no matter whether it is on foreground, background or killed.
So please check your notification payload.