You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
More of a question but notice we don't have a Discussions section here.
I've set up this plugin in our .Net MAUI 9 app. All seems good for receiving and handling notifications from FCM.
However, in our app we can 'defer' a notification, i.e. we receive a notification, tap on it, the app opens and prompts us if we want to action this notification. We can defer the notification, which in turn creates a local notification (a copy of the notification received from FCM) so the user has a reminder to check later.
Here is the code where we create and send our local notification:
const int SHARED_CHANNEL_ID = 2; // any unknown notification_type get re-posted on this channel
const string SHARED_CHANNEL_NAME = "shared";
Dictionary<string, int> knownNotificationTypes = new Dictionary<string, int>
{
{ SHARED_CHANNEL_NAME, SHARED_CHANNEL_ID },
{ "events", 3 },
{ "eventsrepost", 0 }, // channel 0 is used for remote notifications, so reposts on the incoming channel
{ "permits", 5 },
{ "permitsrepost", 0 },
{ "bookings", 7 },
{ "bookingsrepost", 0 }
};
public void SendNotification(string notificationType, string title, string message, object data)
{
Log.Info(TAG, $"{nameof(SendNotification)} type {notificationType} title {title} message {message}");
Intent intent = new Intent(AndroidApp.Context, typeof(MainActivity));
intent.PutExtra("notification_type", notificationType);
intent.PutExtra("summary", title);
intent.PutExtra("details", message);
intent.PutExtra("custom_data", data as string);
intent.AddFlags(ActivityFlags.ClearTop);
PendingIntent pendingIntent = null;
var pendingIntentFlags = (Build.VERSION.SdkInt >= BuildVersionCodes.S)
? PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Mutable
: PendingIntentFlags.UpdateCurrent;
pendingIntent = PendingIntent.GetActivity(AndroidApp.Context, pendingIntentId++, intent, pendingIntentFlags);
notificationType = notificationType.ToLower();
if (!knownNotificationTypes.TryGetValue(notificationType, out int channelId))
{
channelId = SHARED_CHANNEL_ID ;
notificationType = SHARED_CHANNEL_NAME ;
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(AndroidApp.Context, notificationType)
.SetContentIntent(pendingIntent)
.SetContentTitle(title)
.SetContentText(message)
.SetGroup("com.our.appname")
.SetAutoCancel(true)
.SetCategory(notificationType)
.SetSmallIcon(Resource.Drawable.logo_mobile_round_icon)
.SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate);
Notification notification = builder.Build();
_manager.Notify(channelId, notification);
}
This plugin intercepts this notification, but when trying to grab the data out of the notification (either in CrossFirebaseCloudMessaging.Current.NotificationReceived or CrossFirebaseCloudMessaging.Current.NotificationTapped), it is null (title and description are displayed fine).
Just wondering if I'm missing something obvious here.
This discussion was converted from issue #439 on April 15, 2025 19:36.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
More of a question but notice we don't have a Discussions section here.
I've set up this plugin in our .Net MAUI 9 app. All seems good for receiving and handling notifications from FCM.
However, in our app we can 'defer' a notification, i.e. we receive a notification, tap on it, the app opens and prompts us if we want to action this notification. We can defer the notification, which in turn creates a local notification (a copy of the notification received from FCM) so the user has a reminder to check later.
Here is the code where we create and send our local notification:
This plugin intercepts this notification, but when trying to grab the data out of the notification (either in CrossFirebaseCloudMessaging.Current.NotificationReceived or CrossFirebaseCloudMessaging.Current.NotificationTapped), it is null (title and description are displayed fine).
Just wondering if I'm missing something obvious here.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions